SQLite python不更新表

时间:2022-02-09 15:48:13

I have the following code:

我有以下代码:

import sqlite3

con = sqlite3.connect("testDB")
cur = con.cursor()

#cur.execute('CREATE TABLE test_table (id integer primary key, data text)')
cur.execute('INSERT INTO test_table VALUES (?, ?)', (76, 'MyData'))

when I run this script it does not update table. But when I do the same insertion using sqlite3 commandline in Linux, it updates. Why is it so or there anything I am making wrong?

当我运行此脚本时,它不会更新表。但是当我在Linux中使用sqlite3命令行进行相同的插入时,它会更新。为什么这样或有什么我做错了?

2 个解决方案

#1


10  

# Save (commit) the changes
con.commit()

#2


1  

Did you try commiting after the insert clause?

您是否尝试在insert子句后提交?

#1


10  

# Save (commit) the changes
con.commit()

#2


1  

Did you try commiting after the insert clause?

您是否尝试在insert子句后提交?