mxODBC and apostrophe's in strings

Ben C benc1 at
Wed Sep 12 09:28:13 CEST 2001


I am uploading some random text to a MSSQL DB using the mxODBC module.


_text = "This is some really 'extraordinary' text read from a file

_date = 10000232

SQLExpress = "INSERT INTO table (Date, Time) VALUES (" + _date + ",'"
+ _text + "')"


The probelm occurs if an apostrophe appears in the text (I assume
because it has been used as a delimiter in the SQL Expression). The
error message I recieve is similar to this

ProgrammingError: ('37000', 170, "[Microsoft][ODBC SQL Server
Driver][SQL Server]Line 1: Incorrect syntax near 'rline'.", 4523)

Does anyone know of a workaround for this keeping in mind that any
combination of ASCI characters could appear in the _text string.

thanks in advance


More information about the Python-list mailing list