Understanding mxODBC Insert Error

Jon Clements joncle at googlemail.com
Sun Jul 29 18:14:02 EDT 2007


On 29 Jul, 17:41, 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?
>
> CODE
>
> >>> 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'"
> >>> crs.execute(sql)
>
> TRACEBACK
> 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)
>
> --
> View this message in context:http://www.nabble.com/Understanding-mxODBC-Insert-Error-tf4166125.htm...
> Sent from the Python - python-list mailing list archive at Nabble.com.

Apart from what John Machin has said, your SQL also looks like it's
half trying to be an insert with a subselect clause (looking at the
'where') rather than a values clause. Access might well be expecting a
semicolon after the values statement, as the where might be starting
another. Don't have mxODBC, so it's all untested - Just an idea.

Jon.




More information about the Python-list mailing list