From: Will R. <wr...@ra...> - 2003-09-17 10:28:37
|
Is there any way to execute queries containing unicode characters? such as this... select 'ø' I'm using version 0.36 of the Sybase module to talk to MSSQL 2000, python 2.2.2, and FreeTDS version 0.61. I have already managed to migrate 90% of a database (any tables that don't contain unicode characters) using this setup, but I get an error when I try to execute queries containing unicode characters. I am able to insert unicode characters into MSSQL using it's gui tools, then pull them out via python and the Sybase module (as long as the select query itself does not contain unicode characters). Is it possible to make this work? Here is the code sample and the traceback. CODE SAMPLE........ import Sybase conn = Sybase.connect('migration','migration','migration','migration') conn.connect() c = conn.cursor() sql = u"""select '\xf8'""" usql = sql.encode('utf-8') print usql c.execute(usql) print c.fetchall() RESULTS........... select 'ø' Traceback (most recent call last): File "test.py", line 11, in ? c.execute(usql) File "/usr/lib/python2.2/site-packages/Sybase.py", line 687, in execute self.description = fetcher.start(self.arraysize) File "/usr/lib/python2.2/site-packages/Sybase.py", line 442, in start return self._start_results() File "/usr/lib/python2.2/site-packages/Sybase.py", line 546, in _start_results status, result = self._cmd.ct_results() File "/usr/lib/python2.2/site-packages/Sybase.py", line 161, in _servermsg_cb raise DatabaseError(_fmt_server(msg)) Sybase.DatabaseError: Msg 105, Level 15, State 1, Line 1 Unclosed quotation mark before the character string '???'.Msg 170, Level 15, State 1, Line 1 Line 1: Incorrect syntax near '???'. Any help would be greatly appreciated. -- Will |