【发布时间】:2018-07-18 16:58:01
【问题描述】:
我正在使用 psycopg2 将 Postgresql 与 Python 结合使用,但我不确定如何获取“选择更新”查询来使用它。除了 psycopg2,我还可以使用其他东西。如何使用 Python 创建用于更新查询的 postgresql 选择?
【问题讨论】:
标签: python psycopg2 select-for-update
我正在使用 psycopg2 将 Postgresql 与 Python 结合使用,但我不确定如何获取“选择更新”查询来使用它。除了 psycopg2,我还可以使用其他东西。如何使用 Python 创建用于更新查询的 postgresql 选择?
【问题讨论】:
标签: python psycopg2 select-for-update
psycopg2 只是执行您发送到执行方法的字符串中的 sql。您只需像在其他任何地方一样在查询中添加 select for update 即可。
cursor.execute("""select * from some_table for update""")
【讨论】: