Also check out DuckDB, which is a similar tool tailored for data science; I haven’t used it but I’ve heard good things. https://duckdb.org/
* Ensure you're in WAL mode. https://sqlite.org/wal.html
* Use prepared statements and transactions.
* Set the cache pragma to ideally hold the DB in RAM.
* Run optimize and vacuum periodically (especially if the data is transactional): https://sqlite.org/pragma.html#pragma_optimize
* Pick the synchronous mode you're comfortable with: https://sqlite.org/pragma.html#pragma_synchronous
That was what I thought as well, but in this case non-WAL turned out to be faster. Not yet sure why that is.
WAL could have faster writes for small amounts of data, but once you have enough contents that the WAL has to be flushed during processing you're better off skipping the WAL entirely.