News for hackers. Stuff that matters.
Re:Getting the Most Out of Sqlite3 with Python by auxym on Sunday October 22, 2017 @01:34PM (#15527890)
In the past when I've had to insert many rows (for example), I wrapped it inside a transaction. Why and when would someone use executemany() instead? Or does executemany() do a transaction behind the scenes?
Re:Getting the Most Out of Sqlite3 with Python by gaius on Sunday October 22, 2017 @03:32PM (#15528485)
Why and when would someone use executemany() instead?

What kills you in this use case is roundtrips - send one row, wait for an acknowledgement (even if you are not committing it yet) then sent one more, and so on and so on. There is a lot of dead time spent in protocol overheads or just idle. A well implemented executemany() sends as many rows at a time as will fit in a network packet and keeps streaming them as fast as it can.

Re:Getting the Most Out of Sqlite3 with Python by masklinn on Sunday October 22, 2017 @01:42PM (#15527934)
Transactions are a separate orthogonal concern.

What executemany can do is prepare the statement once and call it multiple times with different sets of parameters, whereas execute may be preparing the statement every time it is called (possibly hoping that the database system has a statements cache) or not preparing them at all (and the DBMS only does simple query planning).