Postgres storage: introduce a db() context manager
This helper avoids us repeating the get_db/put_db pattern all the time.
Depends on !255 (closed) because CI is broken without it
Test Plan
no functional change
Migrated from D2066 (view on Phabricator)