db tweaks

- sessions autocommit
- ping_connection guards against connection timeouts
- adjusted session usage to use db.transaction when writing
Merge pull request #651 from seandst/db-module-is-less-terrible

db tweaks