psycopg2“选择更新”

Posted

技术标签:

【中文标题】psycopg2“选择更新”【英文标题】:psycopg2 "select for update" 【发布时间】:2018-07-18 16:58:01 【问题描述】:

我正在使用 psycopg2 将 Postgresql 与 Python 结合使用,但我不确定如何获取“选择更新”查询来使用它。除了 psycopg2,我还可以使用其他东西。如何使用 Python 创建用于更新查询的 postgresql 选择?

【问题讨论】:

【参考方案1】:

psycopg2 只是执行您发送到执行方法的字符串中的 sql。您只需像在其他任何地方一样在查询中添加 select for update 即可。

cursor.execute("""select * from some_table for update""")

【讨论】:

以上是关于psycopg2“选择更新”的主要内容,如果未能解决你的问题,请参考以下文章

尝试使用“pip install psycopg2”在 Mac 上安装 psycopg2 时出现权限错误

安装 psycopg2 osx 10.12 python 3.5.2 - psycopg2 的构建轮失败

当我尝试使用 pip install psycopg2 安装 psycopg2 时,出现此错误。我该怎么办? [复制]

psycopg2 模块无法识别

使用 Psycopg2 将 Spark DataFrame 写入 Redshift 时出错:无法腌制 psycopg2.extensions.cursor 对象

psycopg2的示例