[egenix-users] SQL Server 2000, mxODBC and unicode problem

Marcin tupteq at tlen.pl
Tue Jan 4 17:17:02 CET 2005


Hi,

I recently found mxODBC lib and I decided to use it with MS SQL
Server. It worked fine until i tried to use ntext fields and short
INSERT syntax (INSERT INTO tab VALUES(val1, ...)).
The following script:
<CODE>
from mx.ODBC.Windows import *

db = connect('DSN', 'login', 'pass')
db.stringformat = UNICODE_STRINGFORMAT
c = db.cursor()

c.execute('create table zxcvb (x ntext)')
c.execute('insert into zxcvb values(?)', (None,))
c.execute('insert into zxcvb values(?)', (u'anything',))
</CODE>

raises exception in last line and returns:

Traceback (most recent call last):
  File "test.py", line 15, in ?
    c.execute('insert into zxcvb values(?)', (u'anything',))
mxODBC.ProgrammingError: ('37000', 257, '[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type ntext to char is not allowed. Use the CONVERT function to run this query.', 4579)

But it's enough to change last line to:
c.execute('insert into zxcvb (x) values(?)', (u'anything',))
or use other cursor than used with None insert, but this sucks.
Is it my, server, driver or mODBC bug?

Client specs:
Windows XP Home, Python 2.4, mx-base 2.0.6, mxODBC 2.0.7, MS SQL
Server ODBC Driver v.2000.81.9042.00 (2003-10-27)

Server specs:
OS: Windows XP Home
SQL: MS SQL Server 2000 Trial v.8.00.194

-- 
Marcin



More information about the egenix-users mailing list