trouble with mxODBC, unixODBC and MSSQL

E

erik.myllymaki

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;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 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,444
Messages
2,571,709
Members
48,796
Latest member
Greg L.
Top