Q. What are the basic steps to connect with MySQL using table Members?


Answer :-


import MySQLdb
conn = MySQLdb.connect (host = 'localhost', user = 'user', passwd = 'passwd, db = ‘db’)
cursor = conn.cursor ()
cursor.execute('SELECT COUNT (MemberID) as count FROM Members WHERE id = 1')
row = cursor.fetchone ()
conn.close()
print (row)

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post