0

I am trying to use sqlite3's executemany() to insert multiple values with Python3.

Code:

import sqlite3
conn = sqlite3.connect('rssnewsdata.db')
c = conn.cursor()

entries = [
    ('url1', 1234, 'title1', 'summary1', 'feedurl1'),
    ('url2', 1235, 'title2', 'summary2', 'feedurl2'),
    ('url3', 1236, 'title3', 'summary3', 'feedurl3'),
    ('url4', 1237, 'title4', 'summary4', 'feedurl4')
]

c.executemany('INSERT INTO entries VALUES (?, ?, ?, ?, ?)', entries)

The db file exists, the table exists, I can use Python3 to SELECT from it, so connecting to it is not a problem. The columns are of TEXT, INTEGER, TEXT, TEXT, TEXT type.

Python reports no errors. What is missing?

1 Answer 1

6

you need to

conn.commit()

after the insert.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.