views:

48

answers:

1

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.

+2  A: 

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

John Machin
yes, thanks, already fixed with the previous one.
creitve
This is the actual problem in the above code that would cause the table to be empty. The connection will close when the script exits.
postfuturist
@cretive: consider changing your accepted answer ;-)
John Machin
Yes, updated accepted answer.
creitve