Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite python does not update table

Tags:

python

sql

sqlite

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?

like image 714
user873286 Avatar asked Mar 21 '12 11:03

user873286


1 Answers

# Save (commit) the changes
con.commit()
like image 162
kev Avatar answered Sep 19 '22 02:09

kev