使用sqlalchemy.sql.text()时找不到sqlalchemy命名游标

时间:2015-02-07 04:23:48

标签: python sqlalchemy flask-sqlalchemy psycopg2 alembic

运行良好:

with conn.connection.cursor(name='migration_cursor') as ss_cur:
    ss_cur.execute("SELECT id, stuff FROM cart WHERE stuff_type={}".format(some_variable))

然而,这失败了:

from sqlalchemy.sql import text
with conn.connection.cursor(name='migration_cursor') as ss_cur:
    ss_cur.execute(text("SELECT id, stuff FROM cart WHERE stuff_type=:some_variable"), some_variable=some_variable)

出现此错误消息:

psycopg2.OperationalError: cursor "migration_cursor" does not exist

0 个答案:

没有答案