0

I have this simple python sqlite code to execute a simple SQL statement.

import sqlite3
db_pathname = "./data/db.sqlite3"
sqlite_conn = sqlite3.connect(db_pathname)
sqlite_cur = sqlite_conn.cursor()

sql_statement = """INSERT OR REPLACE INTO table_infos (code, name) VALUES('XL2.SO', 'AGOS Pte')"""
sqlite_cur.execute(sql_statement)

I do not see a new record being added to the sqlite database after running the code. However, if I run the SQL statement manually using a sqlite tool called DB Browser, a new record is added.

I am using python 3.6 and sqlite3.

1 Answer 1

3

You need to commit the changes.

sqlite_cur.execute(sql_statement)
sqlite_conn.commit()
Sign up to request clarification or add additional context in comments.

1 Comment

or can add isolation_level=None like this sqlite3.connect('sqlitedb.db', isolation_level=None). Which does auto commit

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.