SQLAlchemy ExecutionContext.postfetch_cols不存在

时间:2012-06-07 00:29:06

标签: python sqlalchemy

我查看了 ExecutionContext 类下的源 sqlalchemy / engine / base.py ,并且它没有记录这个方法postfetch_cols()。我已经检查过0.7.7,0.6.9稳定版本以及0.8 我是傻又错过了什么?

当我这样做时,还检查了该方法不存在:

from sqlalchemy import *
engine = create_engine('sqlite:///:memory:')
metadata = MetaData(bind=engine)
t = Table('tableName', metadata, Column('a', String), Column('b', Integer) )
t.create()
engine.execute( t.insert(), {'a':'1', 'b':2} )
res = engine.execute(text('select * from tableName'))
res.postfetch_cols() #or res.context.postfetch_cols()

# AttributeError: 'SQLiteExecutionContext' object has no attribute 'postfetch_cols'

sqlalchemy docs: http://docs.sqlalchemy.org/en/rel_0_7/core/connections.html?highlight=postfetch_cols#sqlalchemy.engine.base.ResultProxy.postfetch_cols

2 个答案:

答案 0 :(得分:0)

文档中列出的函数是复数(postfetch_cols),但您以单数形式使用它(postfetch_col)。

这只是你的粘贴中的错字吗?

答案 1 :(得分:0)

postfetch_cols()仅适用于可能已触发默认值的INSERT和UPDATE语句。目前,执行上下文不会采取放置空白集合(或引发错误)的步骤,如果此集合不适用的语句。

相关问题