diff --git a/indexer_worker/indexer_worker/db_helpers.py b/indexer_worker/indexer_worker/db_helpers.py index 6d8ea76e7f9..e0074dd01a3 100644 --- a/indexer_worker/indexer_worker/db_helpers.py +++ b/indexer_worker/indexer_worker/db_helpers.py @@ -2,7 +2,7 @@ import time from typing import NamedTuple -import psycopg2 +import psycopg from decouple import config @@ -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) diff --git a/indexer_worker/indexer_worker/queries.py b/indexer_worker/indexer_worker/queries.py index 9f6eae56dda..cb57ef77982 100644 --- a/indexer_worker/indexer_worker/queries.py +++ b/indexer_worker/indexer_worker/queries.py @@ -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]: diff --git a/indexer_worker/pdm.lock b/indexer_worker/pdm.lock index be02d6c0ca1..21f9c6f69bf 100644 --- a/indexer_worker/pdm.lock +++ b/indexer_worker/pdm.lock @@ -2,10 +2,10 @@ # It is not intended for manual editing. [metadata] -groups = ["default", "dev"] -strategy = ["cross_platform", "inherit_metadata"] +groups = ["default", "dev", "test"] +strategy = ["inherit_metadata"] lock_version = "4.5.0" -content_hash = "sha256:72055fd6c4aa2ae4dd946913e0d1994e52de02287479132dfb04796821b76094" +content_hash = "sha256:f7bedd77012aa43cc7f18d56191f1411e60643a0c32aa4ac96631a0cf032fb99" [[metadata.targets]] requires_python = "==3.12.*" @@ -29,7 +29,7 @@ name = "attrs" version = "23.2.0" requires_python = ">=3.7" summary = "Classes Without Boilerplate" -groups = ["default", "dev"] +groups = ["default", "test"] dependencies = [ "importlib-metadata; python_version < \"3.8\"", ] @@ -136,7 +136,7 @@ name = "colorama" version = "0.4.6" requires_python = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" summary = "Cross-platform colored terminal text." -groups = ["dev"] +groups = ["dev", "test"] marker = "sys_platform == \"win32\"" files = [ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, @@ -241,7 +241,7 @@ files = [ name = "furl" version = "2.1.3" summary = "URL manipulation made simple." -groups = ["dev"] +groups = ["test"] dependencies = [ "orderedmultidict>=1.0.1", "six>=1.8.0", @@ -282,7 +282,7 @@ name = "iniconfig" version = "2.0.0" requires_python = ">=3.7" summary = "brain-dead simple config-ini parsing" -groups = ["dev"] +groups = ["test"] files = [ {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, @@ -342,7 +342,7 @@ name = "jsonschema" version = "4.22.0" requires_python = ">=3.8" summary = "An implementation of JSON Schema validation for Python" -groups = ["default", "dev"] +groups = ["default", "test"] dependencies = [ "attrs>=22.2.0", "importlib-resources>=1.4.0; python_version < \"3.9\"", @@ -361,7 +361,7 @@ name = "jsonschema-specifications" version = "2023.12.1" requires_python = ">=3.8" summary = "The JSON Schema meta-schemas and vocabularies, exposed as a Registry" -groups = ["default", "dev"] +groups = ["default", "test"] dependencies = [ "importlib-resources>=1.4.0; python_version < \"3.9\"", "referencing>=0.31.0", @@ -389,7 +389,7 @@ files = [ name = "orderedmultidict" version = "1.0.1" summary = "Ordered Multivalue Dictionary" -groups = ["dev"] +groups = ["test"] dependencies = [ "six>=1.8.0", ] @@ -403,7 +403,7 @@ name = "packaging" version = "24.1" requires_python = ">=3.8" summary = "Core utilities for Python packages" -groups = ["default", "dev"] +groups = ["default", "test"] files = [ {file = "packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124"}, {file = "packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002"}, @@ -439,7 +439,7 @@ name = "pluggy" version = "1.5.0" requires_python = ">=3.8" summary = "plugin and hook calling mechanisms for python" -groups = ["dev"] +groups = ["test"] files = [ {file = "pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669"}, {file = "pluggy-1.5.0.tar.gz", hash = "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1"}, @@ -450,7 +450,7 @@ name = "pook" version = "2.0.0" requires_python = ">=3.8" summary = "HTTP traffic mocking and expectations made easy" -groups = ["dev"] +groups = ["test"] dependencies = [ "furl>=0.5.6", "jsonschema>=2.5.1", @@ -476,15 +476,19 @@ files = [ ] [[package]] -name = "psycopg2" -version = "2.9.9" -requires_python = ">=3.7" -summary = "psycopg2 - Python-PostgreSQL Database Adapter" +name = "psycopg" +version = "3.2.3" +requires_python = ">=3.8" +summary = "PostgreSQL database adapter for Python" groups = ["default"] +dependencies = [ + "backports-zoneinfo>=0.2.0; python_version < \"3.9\"", + "typing-extensions>=4.6; python_version < \"3.13\"", + "tzdata; sys_platform == \"win32\"", +] files = [ - {file = "psycopg2-2.9.9-cp312-cp312-win32.whl", hash = "sha256:d735786acc7dd25815e89cc4ad529a43af779db2e25aa7c626de864127e5a024"}, - {file = "psycopg2-2.9.9-cp312-cp312-win_amd64.whl", hash = "sha256:a7653d00b732afb6fc597e29c50ad28087dcb4fbfb28e86092277a559ae4e693"}, - {file = "psycopg2-2.9.9.tar.gz", hash = "sha256:d1454bde93fb1e224166811694d600e746430c006fbb031ea06ecc2ea41bf156"}, + {file = "psycopg-3.2.3-py3-none-any.whl", hash = "sha256:644d3973fe26908c73d4be746074f6e5224b03c1101d302d9a53bf565ad64907"}, + {file = "psycopg-3.2.3.tar.gz", hash = "sha256:a5764f67c27bec8bfac85764d23c534af2c27b893550377e37ce59c12aac47a2"}, ] [[package]] @@ -524,7 +528,7 @@ name = "pytest" version = "8.3.3" requires_python = ">=3.8" summary = "pytest: simple powerful testing with Python" -groups = ["dev"] +groups = ["test"] dependencies = [ "colorama; sys_platform == \"win32\"", "exceptiongroup>=1.0.0rc8; python_version < \"3.11\"", @@ -543,7 +547,7 @@ name = "pytest-order" version = "1.2.1" requires_python = ">=3.6" summary = "pytest plugin to run your tests in a specific order" -groups = ["dev"] +groups = ["test"] dependencies = [ "pytest>=5.0; python_version < \"3.10\"", "pytest>=6.2.4; python_version >= \"3.10\"", @@ -557,7 +561,7 @@ files = [ name = "pytest-sugar" version = "1.0.0" summary = "pytest-sugar is a plugin for pytest that changes the default look and feel of pytest (e.g. progressbar, show tests that fail instantly)." -groups = ["dev"] +groups = ["test"] dependencies = [ "packaging>=21.3", "pytest>=6.2.0", @@ -614,7 +618,7 @@ name = "referencing" version = "0.35.1" requires_python = ">=3.8" summary = "JSON Referencing + Python" -groups = ["default", "dev"] +groups = ["default", "test"] dependencies = [ "attrs>=22.2.0", "rpds-py>=0.7.0", @@ -670,7 +674,7 @@ name = "rpds-py" version = "0.18.1" requires_python = ">=3.8" summary = "Python bindings to Rust's persistent data structures (rpds)" -groups = ["default", "dev"] +groups = ["default", "test"] files = [ {file = "rpds_py-0.18.1-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:3dd3cd86e1db5aadd334e011eba4e29d37a104b403e8ca24dcd6703c68ca55b3"}, {file = "rpds_py-0.18.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:05f3d615099bd9b13ecf2fc9cf2d839ad3f20239c678f461c753e93755d629ee"}, @@ -771,7 +775,7 @@ name = "six" version = "1.16.0" requires_python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" summary = "Python 2 and 3 compatibility utilities" -groups = ["default", "dev"] +groups = ["default", "dev", "test"] files = [ {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, @@ -797,7 +801,7 @@ name = "termcolor" version = "2.5.0" requires_python = ">=3.9" summary = "ANSI color formatting for output in terminal" -groups = ["dev"] +groups = ["test"] files = [ {file = "termcolor-2.5.0-py3-none-any.whl", hash = "sha256:37b17b5fc1e604945c2642c872a3764b5d547a48009871aea3edd3afa180afb8"}, {file = "termcolor-2.5.0.tar.gz", hash = "sha256:998d8d27da6d48442e8e1f016119076b690d962507531df4890fcd2db2ef8a6f"}, @@ -842,6 +846,18 @@ files = [ {file = "typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"}, ] +[[package]] +name = "tzdata" +version = "2024.2" +requires_python = ">=2" +summary = "Provider of IANA time zone data" +groups = ["default"] +marker = "sys_platform == \"win32\"" +files = [ + {file = "tzdata-2024.2-py2.py3-none-any.whl", hash = "sha256:a48093786cdcde33cad18c2555e8532f34422074448fbc874186f0abd79565cd"}, + {file = "tzdata-2024.2.tar.gz", hash = "sha256:7d85cc416e9382e69095b7bdf4afd9e3880418a2413feec7069d533d6b4e31cc"}, +] + [[package]] name = "urllib3" version = "2.2.3" @@ -871,7 +887,7 @@ name = "xmltodict" version = "0.13.0" requires_python = ">=3.4" summary = "Makes working with XML feel like you are working with JSON" -groups = ["dev"] +groups = ["test"] files = [ {file = "xmltodict-0.13.0-py2.py3-none-any.whl", hash = "sha256:aa89e8fd76320154a40d19a0df04a4695fb9dc5ba977cbb68ab3e4eb225e7852"}, {file = "xmltodict-0.13.0.tar.gz", hash = "sha256:341595a488e3e01a85a9d8911d8912fd922ede5fecc4dce437eb4b6c8d037e56"}, diff --git a/indexer_worker/pyproject.toml b/indexer_worker/pyproject.toml index 72acfd5fa75..7a641bd8985 100644 --- a/indexer_worker/pyproject.toml +++ b/indexer_worker/pyproject.toml @@ -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", @@ -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]