Using pyodbc to insert rows into a MS Access MDB, how do I escape the paramaters?

Posted by MDBGuy on Stack Overflow See other posts from Stack Overflow or by MDBGuy
Published on 2010-04-08T19:35:58Z Indexed on 2010/04/09 16:53 UTC
Read the original article Hit count: 407

Filed under:
|
|
|
|

Hi,

I'm using pyodbc to talk to a legacy Access 2000 .mdb file.

I've got a cursor, and am trying to execute this:

c.execute("INSERT INTO [Accounts] ([Name], [TypeID], [StatusID], [AccountCat], [id]) VALUES (?, ?, ?, ?, ?)", [u'test', 20, 10, 4, 2])

However, doing so results in

pyodbc.Error: ('HYC00', '[HYC00] [Microsoft][ODBC Microsoft Access Driver]Optional feature not implemented  (106) (SQLBindParameter)')

I understand I can simply change the question marks to the literal values, but in my experience proper escaping of strings across databases is... not pretty.

PHP and mysql team up to bring mysql_real_escape_string and friends, but I can't seem to find pyodbc's function for escaping values.

If you could let me know what the recommended way of inserting this data (from python) is, that'd be very helpful. Alternatively, if you have a python function to escape the odbc strings, that would also be great.

Thanks for the help.

© Stack Overflow or respective owner

Related posts about pyodbc

Related posts about access