(sqlalchemy 0.4.4/pymssql/windows/pylons) Our MS SQL legacy database has column names with spaces and sometimes other special characters. I'm able to get sqlalchemy to work with it by having every column object include quote=True, and by having the mapper() call include: ,properties= {'NameJammed':TableObj.c['Name Jammed'], 'AnotherCol':TableObj.c['Another (Col)']} #etc I can use .NameJammed to access the column in my code just fine.
While I can do this, it's unfortunate under the DRY (Don't Repeat Yourself) philosophy, as we have a long mapper call for each table with each column name in there essentially twice (besides the initial definition.) Mysteries: 1) the key= parameter on the Column() declaration doesn't seem to have any effect. orm/__init__.py's mapper function says under the 'properties' parameter: "Note that the columns in the mapped table are automatically converted into ``ColumnProperty`` instances based on the `key` property of each ``Column`` (although they can be overridden using this dictionary)" 2) Column's quote=True should not be required according to schema.py/ Column/__init__ 'quote' parameter: "indicates that the Column identifier must be properly escaped and quoted before being sent to the database. This flag should normally not be required as dialects can auto-detect conditions where quoting is required" Perhaps I need to update mssql.py to override the right methods, which is pretty intimidating. Can you confirm that, for your database, column names with spaces are automatically quoted (no quote=True required) and that Column's key= works to give a python-identifier name to that column name (no mapper properties required)? Any other illumination? I'd love to have a function auto-generate the "column name without spaces" identifier that I use in my code, too, for even less Repeating Myself. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---