import sqlite conn = sqlite.connect(db="db", mode=077) cursor = conn.cursor() SQL = "select * from person order by lastname" cursor.execute(SQL) row = cursor.fetchone() while row != None: print "%14s, %15s" % (row['firstname'], row['lastname']) row = cursor.fetchone()