Skip to content

Instantly share code, notes, and snippets.

@mvaz
Created March 7, 2012 13:28
Show Gist options
  • Select an option

  • Save mvaz/1993117 to your computer and use it in GitHub Desktop.

Select an option

Save mvaz/1993117 to your computer and use it in GitHub Desktop.
short snippet for querying an access database
# http://code.google.com/p/pyodbc/wiki/GettingStarted
# http://code.google.com/p/pyodbc/wiki/ConnectionStrings
import pyodbc
cnxn_string = r'DRIVER={Microsoft Access Driver (*.mdb)};DBQ=C:\PATH\TO\FILE.mdb'
cnxn = pyodbc.connect(cnxn_string)
cursor = cnxn.cursor()
cursor.execute("SELECT * from MY_TABLE")
rows = cursor.fetchall()
#row = cursor.fetchone()
for row in rows:
print row
cursor.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment