Created
March 7, 2012 13:28
-
-
Save mvaz/1993117 to your computer and use it in GitHub Desktop.
short snippet for querying an access database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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