Skip to content

Instantly share code, notes, and snippets.

@stefanmonkey
Created January 8, 2014 07:21
Show Gist options
  • Save stefanmonkey/8313022 to your computer and use it in GitHub Desktop.
Save stefanmonkey/8313022 to your computer and use it in GitHub Desktop.
fetch one by one
#!/usr/bin/python
# -*- coding: utf-8 -*-
import MySQLdb as mdb
con = mdb.connect('localhost', 'testuser', 'test623', 'testdb');
with con:
cur = con.cursor()
cur.execute("SELECT * FROM Writers")
for i in range(cur.rowcount):
row = cur.fetchone()
print row[0], row[1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment