gpt4 book ai didi

python - 我用于更新 ID = 整数的 MySQL 表的 Python 代码有什么问题?

转载 作者:可可西里 更新时间:2023-11-01 08:16:42 25 4
gpt4 key购买 nike

>>> print x 
[(1,), (2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,)]

>>> for i in range(10):
... if len(x)>0:
... m = random.choice(x)
... x.remove(m)
... y = "%s" %m
... z = int(y)
... cur.execute("""UPDATE accounts SET column = 'YES' WHERE userid = %s""", (z, ))

但这并没有做任何事情。当我查看帐户表时,没有任何变化。

最佳答案

您需要在更新后提交更改:

db.commit()

其中 db 是一个数据库连接实例(connect() 调用的结果)。

另见:Database does not update automatically with MySQL and Python .

关于python - 我用于更新 ID = 整数的 MySQL 表的 Python 代码有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24410890/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com