我一直在试图将数据插入到使用下面的代码在python的数据库:Sqlite插入查询不与python?
import sqlite3 as db
conn = db.connect('insertlinks.db')
cursor = conn.cursor()
db.autocommit(True)
a="asd"
b="adasd"
cursor.execute("Insert into links (link,id) values (?,?)",(a,b))
conn.close()
代码运行没有任何错误。但是不会更新数据库。我试图加入conn.commit()
,但它给出了一个错误,说模块没有找到。请帮忙?
我不确定:是否可能需要在获取游标之前设置自动提交? – Hyperboreus
也尝试过。得到相同的错误'模块'对象没有'自动提交'属性' – user2923505
'AttributeError:'模块'对象没有属性'autocommit''。 'sqlite3'模块上没有这种方法,设置autocommit会有很大的不同。 –