SQLite python does not update table

2019-02-22 18:06发布

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?

2条回答
Juvenile、少年°
2楼-- · 2019-02-22 18:39

Did you try commiting after the insert clause?

查看更多
混吃等死
3楼-- · 2019-02-22 18:47
# Save (commit) the changes
con.commit()
查看更多
登录 后发表回答