Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
query microsoft access 2010 database using python
from __future__ import unicode_literals
import adodbapi
import datetime
database = "Tudeng.mdb"
# access 2010
constr = 'Provider=Microsoft.ACE.OLEDB.12.0; Data Source=%s' % database
# connect to the database
conn = adodbapi.connect(constr)
# create a cursor
cur = conn.cursor()
# extract all the data
sql = '''select * from Aine'''
def row_tuple(item):
return tuple(map(lambda part: unicode(part) if isinstance(part, basestring) or isinstance(part, datetime.datetime) else part, item))
# show the result
result = cur.fetchall()
for row in result:
print row_tuple(row)
# close the cursor and connection

This comment has been minimized.

Copy link

dtrillo commented Jan 21, 2014

Thanks for the example!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.