MS Access db (mdb): viewing table attributes

BartlebyScrivener rpdooling at
Fri Mar 10 17:05:12 EST 2006


This prints the names of the columns in my database.

# Modification of
# Instructions for customizing are at:

import mx.ODBC.Windows as odbc

driv='DRIVER={Microsoft Access Driver (*.mdb)};DBQ=d:/Access

conn = odbc.DriverConnect(driv)
c = conn.cursor()

# get the column names from Table1
c.execute ("SELECT * FROM Table1")

# get column names
cols= [ i[0] for i in c.description ]
print '\n\ncols=',cols

More information about the Python-list mailing list