SQLite python does not update table

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 the table. But when I do the same insertion using the sqlite3 command line on Linux, it updates. Why is this the case or is there something I'm doing wrong?

+5
source share
2 answers
# Save (commit) the changes
con.commit()
+10
source

Did you try to commit after the insert clause?

+1
source

All Articles