我正在使用psycopg2在Python中使用Postgresql,但我不确定如何使用它来获取“select for update”查询。我也可以使用除了psycopg2之外的其他东西。如何使用Python创建一个postgresql select for update查询?
我正在使用psycopg2在Python中使用Postgresql,但我不确定如何使用它来获取“select for update”查询。我也可以使用除了psycopg2之外的其他东西。如何使用Python创建一个postgresql select for update查询?
psycopg2只是执行您发送到execute方法的字符串中的SQL。您只需像在任何其他地方一样在查询中放置“select for update”即可。
cursor.execute("""select * from some_table for update""")