尝试执行任何简单查询时出现以下错误。我无法弄清楚发生了什么变化。
以下是sqlalchemy(Elixir)类的示例:
class Song(Entity):
using_options(tablename='tbSongs', autoload=True)
using_table_options(schema='apra')
数据库连接正常,类构造正常,因为我可以执行dir(Song)
并查看所有正确的列。但是,简单的查询将无效。
以下是对该类和结果输出的查询:
>>> songs = Song.query.all()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 1729, in all
return list(self)
File "/usr/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 1839, in __iter__
return self._execute_and_instances(context)
File "/usr/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 1854, in _execute_and_instances
result = conn.execute(querycontext.statement, self._params)
File "/usr/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1399, in execute
params)
File "/usr/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1532, in _execute_clauseelement
compiled_sql, distilled_params
File "/usr/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1640, in _execute_context
context)
File "/usr/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1633, in _execute_context
context)
File "/usr/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 325, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.DBAPIError: (Error) ('IM001', '[IM001] [unixODBC][Driver Manager]Driver does not support this function (0) (SQLColAttribute)') 'SELECT [tbSongs_1].[ID_Song] AS [apra_tbSongs_ID_Song], [tbSongs_1].[Album] AS [apra_tbSongs_Album], [tbSongs_1].[Title] AS [apra_tbSongs_Title], [tbSongs_1].[Composer] AS [apra_tbSongs_Composer], [tbSongs_1].[Performer] AS [apra_tbSongs_Performer], [tbSongs_1].[TrackNumber] AS [apra_tbSongs_TrackNumber], [tbSongs_1].[Duration] AS [apra_tbSongs_Duration], [tbSongs_1].[RecordLabel] AS [apra_tbSongs_RecordLabel], [tbSongs_1].[Notes] AS [apra_tbSongs_Notes], [tbSongs_1].[Class] AS [apra_tbSongs_Class], [tbSongs_1].[SongID] AS [apra_tbSongs_SongID], [tbSongs_1].[Deleted] AS [apra_tbSongs_Deleted] \nFROM apra.[tbSongs] AS [tbSongs_1]' ()
>>>
设置详情:
/etc/odbcinst.ini:
[ODBC Drivers]
tds = Installed
[tds]
Driver = /usr/lib/libtdsodbc.so
Setup = /usr/lib/libtdsodbc.so
/etc/odbc.ini:
[ODBC]
Trace = 0
[DBNAME]
Driver = TDS
Trace = No
Server = xx.xx.xx.xx\dbname
Database = dbname
Port = 1433
答案 0 :(得分:1)
我也有这个错误,并降级到unixODBC 2.2.12为我修复它(注意我不能让PyOBDC用2.2.14构建,必须是2.2.12)。我对unix的新版ODBC工具的状态感到相当不安(Freetds 0.91也很成问题)。
答案 1 :(得分:1)
尝试删除预先打包的FreeTDS,unixODBC和pyodbc。使用版本0.91,2.3.0和2.1.9分别从源代码重建对我有用,但这可能是一个棘手的过程。我已经在http://groups.google.com/group/sqlalchemy/browse_thread/thread/971e068032d51dd5
上的SQLAlchemy小组最近的一个帖子中详细介绍了它答案 2 :(得分:0)
您能否提供此事件的ODBC跟踪。我刚刚意识到这个问题,我不能(现在)重现它。所以如果你能把它的日志告诉我,它应该是朝着正确方向迈出的一步。