MS Access db (mdb): viewing table attributes

gau.tai at gau.tai at
Fri Mar 10 19:25:35 CET 2006

Here is the full code I'm using now to try out your sample:

import dbi, odbc
import win32com.client
from pprint import pprint

#sample code to list all tables in the selected database
daoEngine = win32com.client.Dispatch('DAO.DBEngine.36')
dtbs = daoEngine.OpenDatabase('database.mdb')
for table in dtbs.TableDefs:
    if table.Name[:4] <> "MSys" and table.Name[:4] <> "~TMP":

#sample code that will execute a stored query with parameters
dbconn = odbc.odbc('DSN=db; UID=user; PWD=pass')
dbcursor = dbconn.cursor()
dbcursor.execute('execute "result specs" 1')
dbcursor.execute('SELECT column1, column2, COUNT(*) FROM Weight ' +
               'WHERE column1 < column2 ' +
               'GROUP BY column1, column2')

I get the error: dbcursor.execute('SELECT column1, column2, COUNT(*)
FROM Weight ' +
dbi.program-error: [Microsoft][ODBC Microsoft Access Driver] Too few
parameters. Expected 2. in EXEC

More information about the Python-list mailing list