Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python doesn't save data to sqlite db

This is my code:

conn = sqlite3.connect(nnpcconfig.commondb)
cur = conn.cursor()
query = ['2124124', 'test2', 'test3', 'test4', 'test5']
cur.execute("insert into users(id, encpass, sname, name, fname) values (?, ?, ?, ?, ?)", query)
conn.commit
cur.execute("select * from users")
for row in cur:
    print row

This code works, returning row fed to it. But it comes out that once script terminated, table is clear again! Where's the mistake? Of course, table users exists.

like image 265
creitve Avatar asked Aug 20 '10 23:08

creitve


1 Answers

You have another mistake: conn.commit instead of conn.commit()

like image 150
John Machin Avatar answered Oct 10 '22 15:10

John Machin