[egenix-users] egenix mxodbc 3.3.1 and SQLAlchemy

Raghavan, Vinay raghavan.vinay at gmail.com
Wed Apr 15 22:08:16 CEST 2015


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.

-- 
Regards,

raghava
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /mailman-archives/egenix-users/attachments/20150415/38ce7dc9/attachment.htm


More information about the egenix-users mailing list