psycopg2。更改光标工厂以进行单个查询
我使用 RealDictRow
光标作为默认光标。但对于某些特定查询,常规(元组)游标更方便。 psycopg2 是否允许在单个查询期间替换游标?
使用示例:
cursor.execute('SELECT id FROM posts', cursor_factory=None)
# Not working, unexpected argument
I'm using RealDictRow
cursor as default cursor. But For some specific queries regular (tuple) cursor is more handy. Is psycopg2 allows to replace cursor during a single query?
Usage example:
cursor.execute('SELECT id FROM posts', cursor_factory=None)
# Not working, unexpected argument
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法更改现有游标的类型,但可以在声明新游标时覆盖连接的
cursor_factory
:You can't change the type of an existing cursor, but you can override the connection's
cursor_factory
when declaring a new cursor: