Consider the following code:
importMySQLdb
d b = M y S Q L d b. c o n n e c t (‘ l o c a l h o s t ’ ,
‘LIBMAN’,‘Admin@pwd’,‘library’)
cursor=db.cursor(prepared=TRUE)
sql = “””Insert into table(‘MemId’,
‘MemName’,‘MemAdd’,)values(‘%s’,‘%s’,‘%s’, )”””
insert_value=[(‘1021’, ‘Ronit’, ’12, Block A, Kaveri
Vihar’),
(‘1022’, ‘Smriti’, ‘12/9 Indira Puram’)]
try:
cursor.executemany(sql,insert_value)
print(cursor.rowcount,“Recordsinserted”)
db.commit()
except:
db.rollback()
cursor.close()
db.close()
Q. What of the following statement is connecting database server?
Correct answer is option 'B'. Can you explain this answer?