# Collection of code snippets by Arne Vajhøj 
# (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import MySQLdb

con = MySQLdb.connect(host="localhost", user="root" , passwd="", db="Test")
stmt = con.cursor()

stmt.execute("SELECT f1,f2 FROM t1")
rs = stmt.fetchall()
for row in rs:
    print row[0]," ",row[1]

stmt.execute("SELECT f1,f2 FROM t1")
while True:
    row = stmt.fetchone()
    if row == None:
        break
    print row[0]," ",row[1]
