我第一次使用sqlite
。我之前使用过Xammp。现在我在这里有一个场景。每次运行下面的代码时,记录都不会附加在表的末尾,而是表被创建为新的,因此它就像控制台一样工作。为什么记录没有保存在sqlite3中?
任何人都可以告诉我我在做什么错吗?
import sqlite3
db = sqlite3.connect('test.db')
db.row_factory = sqlite3.Row
db.execute('drop table if exists test')
db.execute('create table test (t1 text,i1 text)')
db.execute('insert into test (t1, i1) values (?, ?)',('xyzs','51'))
cursor = db.execute('select * from test')
for row in cursor:
print(row['t1'],row['i1'])
那我该怎么办? @ user2864740 – Nabin