Understanding mxODBC Insert Error

John Machin sjmachin at lexicon.net
Sun Jul 29 23:41:45 CEST 2007

On Jul 30, 2:41 am, Greg Corradini <gregcorrad... at gmail.com> wrote:
> Hello,
> I'm trying to perform a simple insert statement into a table called
> Parcel_Test (see code below). Yet, I get an error message that I've never
> seen before (see traceback below). I've tried to put a semicolon at the end
> of the sql statement, but with no luck. Any ideas from more experienced
> mx.ODBC users?

You tried to put a semicolon at the end of the SQL statement, but you
failed? Luck?? I would have thought it needed only steady hands and a
minimally functional text editor.

> >>> driv='DRIVER={Microsoft Access Driver (*.mdb)};DBQ='+workspace
> >>> conn = odbc.DriverConnect(driv)
> >>> crs = conn.cursor()
> >>> sql = "INSERT into Parcel_Test(NEAR_FID,NEAR_DIST) values
> >>> ('0.000000','0.000000') where PIN_ID = '042822120008'"

Are you sure that that is exactly what you ran? I'm not familiar with
"pyshell", but I'd expect an error message (SyntaxError: EOL while
scanning single-quoted string) on the line that starts with "sql =".

At this stage do this to see exactly what you've got:
   print repr(sql)
Maybe this pyshell gadget is trying to do statment continuation and

> >>> crs.execute(sql)
> Traceback (most recent call last):
>   File "<pyshell#1>", line 1, in ?
>     crs.execute(sql)
> ProgrammingError: ('37000', -3516, '[Microsoft][ODBC Microsoft Access
> Driver] Missing semicolon (;) at end of SQL statement.', 4612)

Suggestions: Type your code snippet into a text editor. Get whatever
help you need with the semicolon. Save the snippet to a .py file. Run
the .py file from your operating system's command line (not from
"pyshell"). Show us the full traceback and the contents of your .py
file. It might also help to mention what OS, what version of Python,
and what version of mxODBC.


More information about the Python-list mailing list