Skip to content

Commit

Permalink
Update psycopg2 to psycopg (v3) (#5161)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvkb authored Nov 13, 2024
1 parent 0fe2eb4 commit 4293f21
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 35 deletions.
6 changes: 3 additions & 3 deletions indexer_worker/indexer_worker/db_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import time
from typing import NamedTuple

import psycopg2
import psycopg
from decouple import config


Expand Down Expand Up @@ -43,10 +43,10 @@ def database_connect(
"""
while True:
try:
conn = psycopg2.connect(**dbconfig._asdict(), connect_timeout=timeout)
conn = psycopg.connect(**dbconfig._asdict(), connect_timeout=timeout)
if autocommit:
conn.set_session(autocommit=True)
except psycopg2.OperationalError as e:
except psycopg.OperationalError as e:
if not attempt_reconnect:
return None
log.exception(e)
Expand Down
2 changes: 1 addition & 1 deletion indexer_worker/indexer_worker/queries.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from psycopg2.sql import SQL, Identifier, Literal
from psycopg.sql import SQL, Identifier, Literal


def get_existence_queries(model_name: str, table_name: str) -> tuple[SQL, SQL]:
Expand Down
72 changes: 44 additions & 28 deletions indexer_worker/pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions indexer_worker/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies = [
"filelock ~= 3.13",
"gunicorn ~= 22.0",
"jsonschema ~= 4.19",
"psycopg2 ~= 2.9",
"psycopg >=3.2.3, <4",
"python-decouple ~= 3.8",
"PyYAML ~= 6.0",
"tldextract ~= 5.0",
Expand All @@ -32,11 +32,13 @@ distribution = false
[tool.pdm.dev-dependencies]
dev = [
"ipython~=8.16",
"remote-pdb~=2.1",
]
test = [
"pook~=2.0",
"pytest~=8.3",
"pytest-order~=1.1",
"pytest-sugar~=1.0",
"remote-pdb~=2.1",
"pook~=2.0",
]

[build-system]
Expand Down

0 comments on commit 4293f21

Please sign in to comment.