Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update psycopg2 to psycopg (v3) #5161

Merged
merged 4 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading