# 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 pymssql

con = pymssql.connect(host="localhost", user="sa", password="", database="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]

con.close()
