[egenix-users] mxODBC Cursor Unicode issue with method executedirect().

M.-A. Lemburg mal at egenix.com
Wed Aug 15 17:21:29 CEST 2007


Cliff,

your problem seems to be related to the problem reported by Harri
Pesonen. We will be releasing mxODBC 3.0.1 in the next few days
which includes a work-around for the SQL Server problem with
.executedirect(). This should also fix the problem you are seeing.

Note that .executedirect() is normally only useful for one-shot
queries that don't require parameters. Depending on the ODBC
driver implementation it bypasses the normal processing done
in the ODBC driver and sends off the query directly to the
server.

This can result in better performance, however, it also means
that the ODBC driver doesn't have any type information available
which usually results in less data type conversions and thus
reduces memory foot-print and avoids extensive copying.

For queries which take parameters it is therefore often better
to use the standard .execute() method.

Regards,
-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Aug 15 2007)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611


On 2007-08-07 15:26, Cliff Xuan wrote:
> I had a problem when using unicode object in mxODBC Cursor's executedirect() method.
> 
> These are the lines from my test code:
> 
> u'\xe5' is the Unicode object for Norwegian vow å, spFindUser is a MS SQLServer stored procedure which returns the columns which contains the character in the parameter. 
> 
> Method execute() returns the right result, but executedirect doesn't.
> 
>  
> 
> con = mx.ODBC.Windows.DriverConnect(dsn)
> 
> con.encoding='utf-8'
> 
> selectsql = "{call spFindUser(?)}"
> 
> cur.execute(selectsql, (u'\xe5'))
> 
> cur.executedirect(selectsql, (u'\xe5'))
> 
>  
> 
> Any idea why it's happening?
> 
> This is the explanation of method executedirect() in the official documentation:
> 
>  
> 
> .executedirect(operation[,parameters]) 
> 
> Just like .execute(), except that no prepare step is issued and the operation is not cached. This can result in better performance with some ODBC driver setups, but also implies that Python type binding mode is used to bind the parameters.
> 
> operation may be a Unicode object in case the ODBC driver and/or database support this.
> 
> Return values are not defined.
> 
>  
> 
> One questions on this:  
> 
> What does 'prepare step' mean?
> 
>  
> 
> Many thanks
> 
> Cliff 
> 
>  
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> 
> _______________________________________________________________________
> eGenix.com User Mailing List                     http://www.egenix.com/
> https://www.egenix.com/mailman/listinfo/egenix-users



More information about the egenix-users mailing list