[egenix-users] egenix mxodbc 3.3.1 and SQLAlchemy

M.-A. Lemburg mal at egenix.com
Wed Apr 15 19:00:39 CEST 2015


Hi Vinay,

the error you are seeing basically means that the ODBC driver
does not return a correct .rowcount value. mxODBC does support
.rowcount, but whether it actually works depends on the ODBC
driver used to access the database and the database backend
itself (several databases don't provide this information,
since it is sometimes expensive to calculate).

We can look into this, but would have to know which SQL Server
version you are using, since different backend version behave
differently.

Also: Could you send the traceback you are getting. This
will have a hint to what .rowcount returns.

Do you have example code for the select failure with 0.9.0 ?

Note that we do not maintain the SA backend for mxODBC.
We do send licenses to Michael Bayer so that he can test
with mxODBC (including for the 3.3 release).

Regards,
-- 
Marc-Andre Lemburg
eGenix.com

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

::::: Try our mxODBC.Connect Python Database Interface 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
               http://www.egenix.com/company/contact/


On 15.04.2015 17:38, Raghavan, Vinay wrote:
> Has anyone got egenix 3.3.X to work with recent versions of SQLAlchemy
> (0.8.X / 0.9.X) ?
> 
> With egenix mxodbc 3.3.1 (mx base 3.2.8) we are facing troubles when
> working with
> 
> SQLAlchemy 0.7.6, as the ORM
> unixODBC 2.3.0, as the driver manager
> FreeTDS 0.82 or Microsoft ODBC Driver 11 for SQL Server on Linux (
> https://msdn.microsoft.com/en-us/library/hh568451%28v=sql.110%29.aspx) as
> the db drivers
> 
> Update statements end up throwing StaleDataError. Has anyone encountered
> StaleDataError with latest egenix mxodbc and resolved it; and with which
> version of SQLAlchemy?
> 
> When digging further, with respect to the StaleDataError, a snippet seems
> to have this condition (
> https://github.com/zzzeek/sqlalchemy/blob/rel_0_7_6/lib/sqlalchemy/orm/persistence.py#L478
> onwards)
> 
>    394        if value_params:
>    395            c = connection.execute(
>    396                                statement.values(value_params),
>    397                                params)
>    398        else:
>    399            c = cached_connections[connection].\
>    400                                execute(statement, params)
> 
>    401        _postfetch(
>    402                mapper,
>    403                uowtransaction,
>    404                table,
>    405                state,
>    406                state_dict,
>    407                c.context.prefetch_cols,
>    408                c.context.postfetch_cols,
>    409                c.context.compiled_parameters[0],
>    410                value_params)
>    411        rows += c.rowcount
> 
>    412    if connection.dialect.supports_sane_rowcount:
>    413        if rows != len(update):
>    414            raise orm_exc.StaleDataError(
>    415                    "UPDATE statement on table '%s' expected to "
>    416                    "update %d row(s); %d were matched." %
>    417                    (table.description, len(update), rows))
> 
> pdb shows that connection.dialect.supports_sane_rowcount is set to True
> since it is not overridden otherwise for mxodbc dialect. Is this proper? I
> got this doubt since it is explicitly set otherwise in dialect for pymssql (
> https://github.com/zzzeek/sqlalchemy/blob/rel_0_7_6/lib/sqlalchemy/dialects/mssql/pymssql.py#L53
> )
> 
> Looking at the history, (
> https://github.com/zzzeek/sqlalchemy/commits/master/lib/sqlalchemy/dialects/mssql/mxodbc.py
> ) not many changes have happened after egenix mxodbc 3.2.1 certified for
> SQLAlchemy 0.8.0b1 (
> https://github.com/zzzeek/sqlalchemy/commit/7e815c67a9b90774fbb9fa1865a7d79113ef3612#diff-e4eb329834da3d36278b1b7d943b3bc9L613
> )
> 
> Right now, few of our team members are using FreeTDS and few others using
> MS ODBC driver. The mentioned error is seen with either of these drivers.
> Upgrading to a newer version of SQLAlchemy 0.9.X causes even selects to
> fail, which seems to be a bigger concern.
> 
> Please share any inputs which you may have about the combination of
> unixODBC, FreeTDS, SQLAlchemy and egenix mxodbc.
> 
> 
> 
> 
> _______________________________________________________________________
> 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