Migration to psycopg3
This commit is contained in:
parent
61cfd77da1
commit
08fda328be
4 changed files with 8 additions and 10 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -7,7 +7,7 @@ launchpadlib
|
|||
looseversion
|
||||
lxml
|
||||
mercurial
|
||||
psycopg2
|
||||
psycopg
|
||||
pyreadr
|
||||
python_debian
|
||||
repomd
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue