import MySQLdb
db = MySQLdb.connect(host="localhost",
     user="root",passwd="secret", db="PythonU")
cursor = db.cursor()
recs=cursor.execute("SELECT * FROM Students")
for x in range(recs):
    print(cursor.fetchone())

This code is part of the book "Python for Bioinformatics", by Sebastian Bassi (sbassi@genesdigitales.com). Return to home page.