Extract the BaseDb class from swh-storage
This class is meant to be used not only to wrap storage-like db.
Also rewrite the test_logger using pytest-postgresql fixture so we do not need pifpaf anymore.
Related to T1495
Migrated from D996 (view on Phabricator)