Reimplement swh_db_version with psycopg2
This allows us to reuse an existing connection if needed, and to be more specific which errors we ignore or not.
Test Plan
ran swh db-init on some modules successfully
Migrated from D3992 (view on Phabricator)