1. Michael Bayer
  2. sqlalchemy
  3. Issues

Issues

Issue #3091 resolved

update description_encoding for pyodbc

Michael Bayer
repo owner created an issue

it seems like our defaults on this are out of date, examine pyodbc behavior re: cursor.description and see if we can either change the default, or put in a detection for it, possibly for 1.0 since this may be destabilizing:

#! coding: utf-8

from sqlalchemy import *

engine = create_engine("mssql+pyodbc://scott:tiger@ms_2008", echo=True,
                        description_encoding='utf8')

colname = u'Заказ.Номер заказа'

m = MetaData()
t = Table(u"Заказы", m, Column(colname, String(30), key='somecol'))

m.drop_all(engine)
m.create_all(engine)

engine.execute(t.insert().values(somecol='some value'))
result = engine.execute(t.select().where(t.c.somecol == 'some value'))
row = result.fetchone()
print row[t.c.somecol]

Comments (11)

  1. Michael Bayer reporter

    patch is attached. a couple of issues. with these fixes, SQL server can pass on test/sql/test_unicode on Py2K and freetds 0.91. py3k is not any better. but this is sort of good for 0.8 really, consider porting it there.

  2. Michael Bayer reporter
    • In the SQL Server pyodbc dialect, repaired the implementation for the description_encoding dialect parameter, which when not explicitly set was preventing cursor.description from being parsed correctly in the case of result sets that contained names in alternate encodings. This parameter shouldn't be needed going forward. fixes #3091

    → <<cset 0add251ea0be>>

  3. Michael Bayer reporter
    • In the SQL Server pyodbc dialect, repaired the implementation for the description_encoding dialect parameter, which when not explicitly set was preventing cursor.description from being parsed correctly in the case of result sets that contained names in alternate encodings. This parameter shouldn't be needed going forward. fixes #3091

    → <<cset a1d9c81f5ac7>>

  4. Michael Bayer reporter
    • In the SQL Server pyodbc dialect, repaired the implementation for the description_encoding dialect parameter, which when not explicitly set was preventing cursor.description from being parsed correctly in the case of result sets that contained names in alternate encodings. This parameter shouldn't be needed going forward. fixes #3091

    Conflicts: test/sql/test_unicode.py

    → <<cset a81d3a23c005>>

  5. Michael Bayer reporter
    • Added statement encoding to the "SET IDENTITY_INSERT" statements which operate when an explicit INSERT is being interjected into an IDENTITY column, to support non-ascii table identifiers on drivers such as pyodbc + unix + py2k that don't support unicode statements. ref #3091 as this fix is also in that issue's patch, but is a different issue.

    → <<cset 2825730e7be6>>

  6. Michael Bayer reporter
    • Added statement encoding to the "SET IDENTITY_INSERT" statements which operate when an explicit INSERT is being interjected into an IDENTITY column, to support non-ascii table identifiers on drivers such as pyodbc + unix + py2k that don't support unicode statements. ref #3091 as this fix is also in that issue's patch, but is a different issue.

    → <<cset 1604b5c08917>>

  7. Michael Bayer reporter
    • Added statement encoding to the "SET IDENTITY_INSERT" statements which operate when an explicit INSERT is being interjected into an IDENTITY column, to support non-ascii table identifiers on drivers such as pyodbc + unix + py2k that don't support unicode statements. ref #3091 as this fix is also in that issue's patch, but is a different issue.

    → <<cset 74d38623ff52>>

  8. Log in to comment