Problem with odbc (pywin32) and unicode

Frank Millman frank at chagford.com
Tue Feb 7 08:44:33 EST 2006


Frank Millman wrote:
> Hi all
>
> I am using odbc from pywin32 to connect to MS SQL Server. I am changing
> my program from the old (incorrect) style of embedding values in the
> SQL command to the new (correct) style of passing the values as
> parameters. I have hit a problem.
>
> The following all work -
>     cur.execute("select * from users where userid = '%s'" % 'frank')  #
> old style
>     cur.execute("select * from users where userid = '%s'" % u'frank')
> # old style
>     cur.execute("select * from users where userid = ?", ['frank'])  #
> new style
>
> This does not work -
>     cur.execute("select * from users where userid = ?", [u'frank'])  #
> new style
>
> I get the following error -
> OdbcError: Found an insert row that didn't have 1 columns [sic]
>
> It is the combination of new style and unicode that does not work.
>
> I realise that odbc is not fully DB-API compliant, but I have got away
> with it up to now. Does anyone know of a solution to this problem?
>
> Thanks
>
> Frank Millman
>

I am pleased to report that this has been fixed.

I have been liaising with Mark Hammond, and he has sent me a revised
version which behaves correctly.

This is from Mark -

"I'd be happy for you to mention this fix will be in build 208 - I just
can't tell you when that will be :)"

Frank




More information about the Python-list mailing list