![](/img/trans.png)
[英]How do I insert variables in the UPDATE Statement sqlite3 with Python?
[英]How do I run the sqlite3 insert statement once in Python?
import sqlite3
conn = sqlite3.connect('test3.db')
cursor = conn.cursor()
cursor.execute("""create table if not exists test(
num integer primary key autoincrement,
name char(5))""")
cursor.execute("insert into test(num, name) values(null, 'andy')")
conn.commit()
for i in cursor.execute("select *from test"):
if int(i[0]) <= 1:
conn.commit()
else:
conn.close()
我将sqlite3值放入wx.combobox
,进行选择,并在更改wx.combobox
值时将更改后的值应用于sqlite3。 我在操作过程中遇到问题,想要修复它。
当您运行程序cursor.execute ("insert into test (num, name) values (null, 'andy')")
此语句继续执行。 运行程序后,如何使程序运行一次?
据我了解,您无需在查询中传递数字,因为它已设置为自动增量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.