gpt4 book ai didi

python - 一切正常,但无法将数据添加到 mysql 数据库

转载 作者:行者123 更新时间:2023-11-30 00:58:58 25 4
gpt4 key购买 nike

我正在尝试向我的数据库添加一些数据。代码运行良好,没有错误。但当我检查数据库时,我发现没有什么新内容。哪里出错了?

import MySQLdb as mdb

con = #connection settings
cur = con.cursor()
cur.execute("""INSERT INTO myData(id,city,district,testval,
test_date,property_type,price,testvar,title,
description,number_of_tester,number_of_test,
test_age,test_number,number_of_tests,heating,test_type,
applicable,usage_type,test_profile,test,
house_type,latitude,longitude,test_name,test_phones,test_profile,
test_desc,test_title)
VALUES (123456,'Baku','Ahmedli rn','Ahmadli',
'2010-11-10 12:00:00','',1,0,'','','',0,'','','','','','','','','','',0,0,'','','','','')""")
con.close()

最佳答案

问题解决了,Python 中的 MySQL 需要在末尾使用 con.commit() 将所有这些添加到数据库中。

关于python - 一切正常,但无法将数据添加到 mysql 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20308283/

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