Bulk insert huge data into SQLite using Python

前端 未结 3 815
你的背包
你的背包 2020-12-01 08:23

I read this: Importing a CSV file into a sqlite3 database table using Python

and it seems that everyone suggests using line-by-line reading instead of using bulk .im

3条回答
  •  日久生厌
    2020-12-01 08:58

    Sqlite can do tens of thousands of inserts per second, just make sure to do all of them in a single transaction by surrounding the inserts with BEGIN and COMMIT. (executemany() does this automatically.)

    As always, don't optimize before you know speed will be a problem. Test the easiest solution first, and only optimize if the speed is unacceptable.

提交回复
热议问题