#! /usr/bin/python import sys import sqlite3 try: # Open a connection to the database conn = sqlite3.connect ('bmi219.db') cursor = conn.cursor() # Execute an SQL statement -- can be pretty much any SQL cursor.execute("SELECT NAME, PROTEIN from GENE") # fetchall returns a list of lists rows = cursor.fetchall() for row in rows: print "%s, %s"%(row[0], row[1]) # Close the cursor and commit any changes to the database cursor.close() conn.commit() except sqlite3.Error, e: print "An error occurred:", e.args[0] conn.close()