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...
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()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.