i have problem with SQLite3 in Python (using PyCharm + Python 3.5 on W10). The insert doesn't work
import sqlite3
conn = sqlite3.connect("test.db")
c = conn.cursor()
c.execute("DROP TABLE Normal;") # to clean data
c.execute("CREATE TABLE Normal (Invoice INTEGER);")
c.execute("INSERT INTO Normal (Invoice) VALUES (24);")
If I run sqlite3.exe in the directory afterwards, open the db and write commands in cmd.exe console:
sqlite> .open test.db;
sqlite> select * from Normal;
sqlite> INSERT INTO Normal (Invoice) VALUES (24);
sqlite> select * from Normal;
24
The very same insert works. I am confused...
1 Answer 1
The python library of SQLITE3 is transactional, meaning that it doesn't commit to the database until you commit the changes.
after the INSERT INTO statement put the line:
conn.commit()
answered Nov 8, 2017 at 20:34
Brendan Samek
2661 silver badge6 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
Explore related questions
See similar questions with these tags.
default
COMMIT?