Refactor db.py.

- Use schema.sql
- Use dev.sqlite
- db connection handling