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

Charlie Clark charlie at egenix.com
Tue Jan 4 19:45:04 CET 2005


Hi,

just a thought, but if have you tried using MIXEDSTRINGFORMAT? It seems that 
switching between encodings is what is upsetting the driver and as 
Marc-André has pointed out None will be passed as a non-unicode "NULL".

Just out of interest, what is wrong with:

> c.execute('insert into zxcvb (x) values(?)', (u'anything',)) ?

> or use other cursor than used with None insert, but this sucks.

Surely, it is always better to explicitly relation attributes in queries?

Charlie

On 2005-01-04 at 17:17:02 [+0100], Marcin <tupteq at tlen.pl> wrote:
> 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?



More information about the egenix-users mailing list