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 varchar field
(\n \r ,etc.).
-----------------------------------------------------------------------------
# conn = mx.ODBC.WINDOWS.DriverConnect('DSN=myDSN;UID=sa;PW D=pwd')
conn = mx.ODBC.unixODBC.DriverConnect('DSN=myDSN;UID=sa;P WD=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 tring 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.