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.