Refactor db_store using context managers

### Motivation
The `db_store` module routinely acquires the following resources on each DB operation: a `dbapi2.Connection` object and a `threading.Lock`. Once the operation is completed, these objects must be released exactly once and in an orderly manner. A number of outstanding bugs attest out failure to do so. This PR attempts to resolve this problem by installing a generic context manager for the DB operations, leveraging the power of the `with` statement. The implementation uses a decorator functor that maps each DB operation to a DB operation with automatic context handling.

### Changelog
* Replace old context set-up and tear-down code with a simple context manager.
* Wrap all public CRUD methods inside the context manager.  
* Do a couple of minor refactors.
* Fixes #761, #929, #931, #938.

### Notes
* This PR along with the fixed issues is the primary deliverable of Beta 3.1. Please review and test thoroughly.
* The `db_store` module is in dire need of further simplification and more rigorous testing; this will be the subject of a future iteration.
:+1: very cool