运行良好:
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