from time import sleep from pyodbc import connect conn = connect("Driver={MySQL ODBC 5.1 Driver};Server=localhost;" "Database=testfetch;User=root;Password=root;OPTION=1048576") c = conn.cursor() c.execute("SELECT COUNT(*) FROM testfetch") print "%d rows to fetch" % c.fetchone()[0] c.execute("SELECT * FROM testfetch") for r in c: print "Row #%d fetched" % r[0] sleep(5) print "No more rows"