[egenix-users] errors using mxODBC with unixODBC to connect to MSSQL

Erik Myllymaki erik.myllymaki at aviawest.com
Sun Apr 2 22:22:12 CEST 2006


I am using a script that's worked for me in the past on Windows, but
now that i've moved it to a Linux machine it is not. The trouble seems
to be when trying to insert escaped characters into a ntext field
(\n \r ,etc.).

-----------------------------------------------------------------------------
# works on Windows using this connect method
# conn = mx.ODBC.WINDOWS.DriverConnect('DSN=myDSN;UID=sa;PWD=pwd')

conn = mx.ODBC.unixODBC.DriverConnect('DSN=myDSN;UID=sa;PWD=pwd')
curr = conn.cursor()

# These strings do not work:
# mystring = "Some text \n and some other text"
# mystring = "Some text \t and some other text"
# mystring = """Some text
and some other text"""

# This string works just fine:
mystring = "Some text and some other text"

sql_insert = "insert into DEV..msg(message_id,body) values(?,?)"

curr.execute(sql_insert, (1,mystring))
curr.close()
conn.commit()
-----------------------------------------------------------------------------

Here's the error message:

Error Type: OperationalError
Error Value: ('', 8179, '[unixODBC][FreeTDS][SQL Server]Could not find
prepared statement with handle 0.', 6083)

Any ideas greatly appreciated.



More information about the egenix-users mailing list