Skip to content

Commit

Permalink
Use psycopg(3) for Python 3.13 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
martinhoyer committed Aug 27, 2024
1 parent a6702db commit 9ddf537
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion python-nitrate.spec
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ Summary: %{summary}
%{?python_provide:%python_provide python3-nitrate}
%if %{with oldreqs}
Requires: python%{python3_pkgversion}-gssapi
Requires: python%{python3_pkgversion}-psycopg2
Requires: python%{python3_pkgversion}-psycopg3
Requires: python%{python3_pkgversion}-six
%endif
Requires: libpq
Conflicts: python2-nitrate < 1.5-3

%description -n python%{python3_pkgversion}-nitrate %_description
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
license='LGPLv2+',
install_requires=[
'gssapi',
'psycopg2',
'psycopg',
'six',
],
url='https://psss.fedorapeople.org/python-nitrate/',
Expand Down
6 changes: 3 additions & 3 deletions source/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"""

import six
import psycopg2
import psycopg

from six.moves import xmlrpc_client as xmlrpclib

Expand Down Expand Up @@ -842,7 +842,7 @@ def _fetch(self, inset=None):
injects = self._teiid.run_cases(self.id)
except teiid.TeiidNotConfigured:
injects = self._server.TestRun.get_test_cases(self.id)
except psycopg2.DatabaseError as error:
except psycopg.DatabaseError as error:
log.debug("Failed to fetch data from Teiid: {0}".format(error))
injects = self._server.TestRun.get_test_cases(self.id)
self._current = set([TestCase(inject) for inject in injects])
Expand Down Expand Up @@ -915,7 +915,7 @@ def _fetch(self, inset=None):
injects = self._teiid.run_case_runs(self.id)
except teiid.TeiidNotConfigured:
injects = self._server.TestRun.get_test_case_runs(self.id)
except psycopg2.DatabaseError as error:
except psycopg.DatabaseError as error:
log.debug("Failed to fetch data from Teiid: {0}".format(error))
injects = self._server.TestRun.get_test_case_runs(self.id)
# Feed the TestRun.testcases container with the initial object
Expand Down
8 changes: 4 additions & 4 deletions source/teiid.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
Teiid support
For enhanced query performance it's possible to use a Teiid instance.
Use the following config snippet to enable access via psycopg2 module:
Use the following config snippet to enable access via psycopg module:
[teiid]
user = username
Expand All @@ -32,7 +32,7 @@
port = 5432
"""

import psycopg2
import psycopg

from nitrate.config import log, Config
from nitrate.xmlrpc_driver import NitrateError
Expand Down Expand Up @@ -74,9 +74,9 @@ def __init__(self):
log.debug("Connecting as {0} to database {1} at {2}:{3}".format(
user, database, host, port))
try:
self.connection = psycopg2.connect(database=database,
self.connection = psycopg.connect(database=database,
user=user, password=password, host=host, port=port)
except psycopg2.DatabaseError as error:
except psycopg.DatabaseError as error:
log.error("Teiid connect error: {0}".format(error))
raise TeiidError("Failed to connect to the Teiid instance")
self.connection.set_isolation_level(0)
Expand Down

0 comments on commit 9ddf537

Please sign in to comment.