db: Use sqlite transactions

This will speedup inserts/updates.  This is very much
visible when sending the first encrypted message to a
room as we insert several rows in a single transaction
2 jobs for wip/sadiq/speedup-db in 4 minutes and 50 seconds (queued for 2 seconds)