diff --git a/requirements-swh.txt b/requirements-swh.txt index 074e961..76a8876 100644 --- a/requirements-swh.txt +++ b/requirements-swh.txt @@ -1,2 +1,2 @@ -swh.core[db] >= 3.4.0 -swh.scheduler >= 2.7.0 +swh.core[db] >= 4.0.0 +swh.scheduler >= 3.0.0 diff --git a/requirements-test.txt b/requirements-test.txt index 4cd12d0..9420286 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -4,7 +4,7 @@ pandas-stubs pytest >= 8.1 pytest-mock requests_mock -swh-scheduler[testing] >= 2.7.0 +swh-scheduler[testing] >= 3.0.0 types-beautifulsoup4 types-click types-dateparser diff --git a/requirements.txt b/requirements.txt index bd20daf..87e2168 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ launchpadlib looseversion lxml mercurial -psycopg2 +psycopg pyreadr python_debian repomd diff --git a/swh/lister/rubygems/lister.py b/swh/lister/rubygems/lister.py index 400a992..aa5593c 100644 --- a/swh/lister/rubygems/lister.py +++ b/swh/lister/rubygems/lister.py @@ -15,7 +15,7 @@ import tempfile from typing import Any, Dict, Iterator, Optional, Tuple from bs4 import BeautifulSoup -import psycopg2 +import psycopg from testing.postgresql import Postgresql from swh.scheduler.interface import SchedulerInterface @@ -87,20 +87,18 @@ class RubyGemsLister(StatelessLister[RubyGemsListerPage]): def create_rubygems_db( self, postgresql: Postgresql - ) -> Tuple[str, psycopg2._psycopg.connection]: + ) -> Tuple[str, psycopg.Connection[Any]]: logger.debug("Creating rubygems database") db_dsn = postgresql.dsn() db_url = postgresql.url().replace(db_dsn["database"], self.DB_NAME) - db = psycopg2.connect(**db_dsn) - db.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT) + db = psycopg.connect(autocommit=True, conninfo=postgresql.url()) with db.cursor() as cursor: cursor.execute(f"CREATE DATABASE {self.DB_NAME}") db_dsn["database"] = self.DB_NAME - db = psycopg2.connect(**db_dsn) - db.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT) + db = psycopg.connect(conninfo=db_url, autocommit=True) with db.cursor() as cursor: cursor.execute("CREATE EXTENSION IF NOT EXISTS hstore")