Mahendra Liya
Mahendra Liya

Reputation: 13218

What is the optimized way to insert large number of records (more than 40,000) in sqlite3

I am trying to insert more than 40,000 records into sqlite3 in one stretch.

What would be the best approach to insert them in least amount of time.

I have used prepared statements in Java and am aware that precompiled sql statements are faster as compared to raw sql queries. I was not able to find a code snippet for insert records using prepared statement inside sqlite3 using python. Any pointers in this direction would be appreciated.

I am even open to any other alternatives to prepared statements.

Thanks.

Upvotes: 1

Views: 2568

Answers (1)

Xavier Combelle
Xavier Combelle

Reputation: 11195

You should use executemany with an appropriate iterator

Upvotes: 7

Related Questions