oSame = oSession.query(UserAction).filter_by(tablename=self.tablename).filter_by(isn=self.isn).filter_by(time_stamp=self.time_stamp).filter_by(command=self.command).filter_by(command_type=self.command_type).filter_by(username=self.username).first()
提出异常:
NotSupportedError: type oid 705 not mapped to py type
最后包含完整(ish)回溯......
所以我认为我会使用消除过程来确定哪个列很奇怪。我想出了这个:
try:
oSame = oSession.query(UserAction).filter_by(tablename=self.tablename).filter_by(isn=self.isn).filter_by(time_stamp=self.time_stamp).filter_by(command=self.command).filter_by(command_type=self.command_type).filter_by(username=self.username).first()
except:
oEx = oSession.query(UserAction).filter_by(tablename=self.tablename).filter_by(isn=self.isn).filter_by(time_stamp=self.time_stamp).filter_by(command=self.command).filter_by(command_type=self.command_type).filter_by(username=self.username).first()
raise Exception(oEx)
这引发了例外:
Exception: <adabas_converter.models.UserAction object at 0x27c7f50>
请注意,oSame使用的表达式与oEX完全相同!这似乎很疯狂。
try:
do_stuff() <----raises exception
except:
do_stuff() <----executes just fine!
所以我的问题是:为什么查询在except子句中成功执行而在原始代码中没有成功执行?
此外,如果我将驱动程序交换到psycopg2
,那么所有这些奇怪的东西都会停止。
原始追溯:
File "/home/criticalid/programs/adabas_converter/models.py", line 53, in __init__
oSame = oSession.query(UserAction).filter_by(tablename=self.tablename).filter_by(isn=self.isn).filter_by(time_stamp=self.time_stamp).filter_by(command=self.command).filter_by(command_type=self.command_type).filter_by(username=self.username).first()
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.4-py2.7-linux-x86_64.egg/sqlalchemy/orm/query.py", line 2333, in first
ret = list(self[0:1])
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.4-py2.7-linux-x86_64.egg/sqlalchemy/orm/query.py", line 2200, in __getitem__
return list(res)
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.4-py2.7-linux-x86_64.egg/sqlalchemy/orm/query.py", line 2404, in __iter__
return self._execute_and_instances(context)
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.4-py2.7-linux-x86_64.egg/sqlalchemy/orm/query.py", line 2417, in _execute_and_instances
close_with_result=True)
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.4-py2.7-linux-x86_64.egg/sqlalchemy/orm/query.py", line 2408, in _connection_from_session
**kw)
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.4-py2.7-linux-x86_64.egg/sqlalchemy/orm/session.py", line 843, in connection
close_with_result=close_with_result)
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.4-py2.7-linux-x86_64.egg/sqlalchemy/orm/session.py", line 847, in _connection_for_bind
return self.transaction._connection_for_bind(engine)
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.4-py2.7-linux-x86_64.egg/sqlalchemy/orm/session.py", line 315, in _connection_for_bind
conn = bind.contextual_connect()
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.4-py2.7-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1729, in contextual_connect
self.pool.connect(),
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.4-py2.7-linux-x86_64.egg/sqlalchemy/pool.py", line 332, in connect
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.4-py2.7-linux-x86_64.egg/sqlalchemy/pool.py", line 626, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.4-py2.7-linux-x86_64.egg/sqlalchemy/pool.py", line 433, in checkout
rec = pool._do_get()
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.4-py2.7-linux-x86_64.egg/sqlalchemy/pool.py", line 945, in _do_get
return self._create_connection()
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.4-py2.7-linux-x86_64.egg/sqlalchemy/pool.py", line 278, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.4-py2.7-linux-x86_64.egg/sqlalchemy/pool.py", line 409, in __init__
exec_once(self.connection, self)
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.4-py2.7-linux-x86_64.egg/sqlalchemy/event/attr.py", line 247, in exec_once
self(*args, **kw)
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.4-py2.7-linux-x86_64.egg/sqlalchemy/event/attr.py", line 257, in __call__
fn(*args, **kw)
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.4-py2.7-linux-x86_64.egg/sqlalchemy/util/langhelpers.py", line 1203, in go
return once_fn(*arg, **kw)
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.4-py2.7-linux-x86_64.egg/sqlalchemy/engine/strategies.py", line 165, in first_connect
dialect.initialize(c)
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.4-py2.7-linux-x86_64.egg/sqlalchemy/dialects/postgresql/base.py", line 1560, in initialize
super(PGDialect, self).initialize(connection)
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.4-py2.7-linux-x86_64.egg/sqlalchemy/engine/default.py", line 250, in initialize
self._check_unicode_description(connection):
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.4-py2.7-linux-x86_64.egg/sqlalchemy/engine/default.py", line 335, in _check_unicode_description
]).compile(dialect=self)
File "/usr/local/lib/python2.7/dist-packages/pg8000-1.08-py2.7.egg/pg8000/dbapi.py", line 243, in _fn
return fn(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pg8000-1.08-py2.7.egg/pg8000/dbapi.py", line 314, in execute
self._execute(operation, args)
File "/usr/local/lib/python2.7/dist-packages/pg8000-1.08-py2.7.egg/pg8000/dbapi.py", line 319, in _execute
self.cursor.execute(new_query, *new_args)
File "/usr/local/lib/python2.7/dist-packages/pg8000-1.08-py2.7.egg/pg8000/interface.py", line 304, in execute
self._stmt.execute(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pg8000-1.08-py2.7.egg/pg8000/interface.py", line 139, in execute
self._row_desc, cmd = self.c.bind(self._portal_name, self._statement_name, args, self._parse_row_desc, kwargs.get("stream"))
File "/usr/local/lib/python2.7/dist-packages/pg8000-1.08-py2.7.egg/pg8000/protocol.py", line 913, in _fn
return fn(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pg8000-1.08-py2.7.egg/pg8000/protocol.py", line 1082, in bind
output_fc = [types.py_type_info(f) for f in row_desc.fields]
File "/usr/local/lib/python2.7/dist-packages/pg8000-1.08-py2.7.egg/pg8000/types.py", line 162, in py_type_info
raise NotSupportedError("type oid %r not mapped to py type" % type_oid)
NotSupportedError: type oid 705 not mapped to py type