1. Michael Bayer
  2. sqlalchemy
  3. Issues

Issues

Issue #3140 invalid

The pyodbc driver truncates the column names

Viktor Nagy
created an issue

Comments (1)

  1. Michael Bayer repo owner

    I have no doubt you are actually having this issue, however I can't reproduce it. There are lots of problems and caveats with Pyodbc and SQL Server in the realm of unicode, especially DDL. Things that help include making sure FreeTDS has the encoding set up, as well as using FreeTDS 0.91 on a linux platform (not on OSX).

    Test case here works fine, if this test case also works for you but you can alter it to show the failure, please do so and reopen:

    from sqlalchemy import *
    from sqlalchemy.orm import *
    from sqlalchemy.ext.declarative import declarative_base
    
    Base = declarative_base()
    
    class Foo(Base):
        __tablename__ = 'D_Allomanylista_Komplex_V'
    
        bar = Column(u'Szerz\u0151d\xe9sSorsz\xe1m', INTEGER(), autoincrement=False, primary_key=True)
    
    e = create_engine("mssql+pyodbc://scott:tiger@ms_2008", echo=True)
    
    c = e.connect()
    t = c.begin()
    
    Base.metadata.create_all(c)
    
    s = Session(c)
    s.add(Foo(bar=5))
    s.commit()
    
    row = s.query(Foo).first()
    
    assert row.bar == 5
    

    output:

    CREATE TABLE [D_Allomanylista_Komplex_V] (
        [SzerződésSorszám] INTEGER NOT NULL, 
        PRIMARY KEY ([SzerződésSorszám])
    )
    
    
    2014-07-24 19:15:22,504 INFO sqlalchemy.engine.base.Engine ()
    2014-07-24 19:15:22,507 INFO sqlalchemy.engine.base.Engine INSERT INTO [D_Allomanylista_Komplex_V] ([SzerződésSorszám]) VALUES (?)
    2014-07-24 19:15:22,507 INFO sqlalchemy.engine.base.Engine (5,)
    2014-07-24 19:15:22,510 INFO sqlalchemy.engine.base.Engine SELECT TOP 1 [D_Allomanylista_Komplex_V].[SzerződésSorszám] AS [D_Allomanylista_Komplex_V_SzerződésSorszám] 
    FROM [D_Allomanylista_Komplex_V]
    
  2. Log in to comment