Wrap preparing the database in a transaction. Otherwise it will take many seconds to complete because sqlite will create a transaction per statement