dbi odbc error

don donald.braman at yale.edu
Thu Apr 4 13:13:44 EST 2002


Nevermind. :-) For any who encounter the same problem, swap double and
single quotes in the sql command.

"don" <donald.braman at yale.edu> wrote in message
news:a8i4hh$htk$1 at news.ycc.yale.edu...
> I'm new to python. I'm trying to update tables in an MS Access database. I
> can connect and retrieve data just fine. The following *does* work well:
>
>                 import dbi, odbc
>                 conn = odbc.odbc(mybase)
>                 cur = conn.cursor()
>                 cur.execute('SELECT * FROM mytable WHERE myfield < 1830')
>                 print cur.description
>                 for tup in cur.description:
>                         print tup[0],
>                 print
>                 while 1:
>                         rec = cur.fetchmany(10)
>                         if not rec: break
>                         print rec
>
> But when I try to update a field the in table, I get an error. So, the
> following does *not* work:
>
>                 import dbi, odbc
>                 conn = odbc.odbc(mybase)
>                 cur = conn.cursor()
>                 cur.execute('UPDATE mytable SET mytable.myfield= "test";')
>                 conn.commit()
>                 cur.close()
>                 conn.close()
>
> The error I get is:
>
>   File "F:\simple update.py", line 4, in ?
>     cur.execute('UPDATE mytable SET mytable.myfield = "test";')
> dbi.program-error: [Microsoft][ODBC Microsoft Access Driver] Too few
> parameters. Expected 1. in EXEC
>
>
>
>
>





More information about the Python-list mailing list