我有一张100多行的桌子。使用Python,我试图让第一行在列A上执行一些操作,并在完成后将列B更新为true
然后我想转到下一行,重复这个过程。 现行代码
def _down():
params = config()
connection = psycopg2.connect(**params)
req = ("BEGIN;")
req2 = ("SELECT id FROM table_name WHERE col2 = False LIMIT 1 FOR UPDATE SKIP LOCKED;")
cursor = connection.cursor()
cursor.execute(req), cursor.execute(req2)
data = cursor.fetchall()
connection.commit()
cursor.close(), connection.close()
我有一个将列b更新为true的查询,但它对整个列而不是特定行执行该查询
req3 = ("update tablename set col2 = True")
目前没有回答
相关问题 更多 >
编程相关推荐