http://kushal76uaid62oup5774umh654scnu5dwzh4u2534qxhcbi4wbab3ad.onion/posts/fetching-row-by-row-from-mysql-in-python.html
We try to do that by the following code import MySQLdb
conn = MySQLdb.connect(user= " user " , passwd= " password " , db= " dbname " )
cur = conn.cursor()
cur.execute( " SELECT id, name FROM students " )
row = cur.fetchone()
while row is not None:
print row[0], row[1]
row = cur.fetchone()
cur.close()
conn.close() But remember that the default cursor fetches all data at once from the
server, it does not matter that if you use fetchall or fetchone .