Skip to content

Commit

Permalink
Merge pull request #43 from level12/42-psycopg3-support
Browse files Browse the repository at this point in the history
support psycopg3
  • Loading branch information
guruofgentoo committed Apr 16, 2024
2 parents 24bff1f + ee0972b commit 0139bea
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pals/core.py
Expand Up @@ -105,7 +105,7 @@ def _acquire(self, blocking=None, acquire_timeout=None) -> bool:
self.conn = self.engine.connect()

if blocking:
timeout_sql = sa.text('set lock_timeout = :timeout')
timeout_sql = sa.text("select set_config('lock_timeout', :timeout :: text, false)")
with self.conn.begin():
self.conn.execute(timeout_sql, {'timeout': acquire_timeout})

Expand Down
13 changes: 12 additions & 1 deletion pals/tests/test_core.py
Expand Up @@ -10,8 +10,19 @@

import pals

try:
import psycopg # noqa: F401

db_driver = 'postgresql+psycopg'
except ImportError:
db_driver = 'postgresql'


# Default URL will work for CI tests
db_url = os.environ.get('PALS_DB_URL', 'postgresql://postgres:password@localhost/postgres')
db_url = os.environ.get(
'PALS_DB_URL',
f'{db_driver}://postgres:password@localhost/postgres'
)


def random_str(length):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -41,7 +41,7 @@
'tests': [
'pytest',
'pytest-cov',
'psycopg2-binary',
'psycopg[binary]',
],
}
)
9 changes: 6 additions & 3 deletions tox.ini
@@ -1,7 +1,7 @@
[tox]
envlist =
py{38,39,310}-{base,stable}
py310-{lowest}
py{39,310,311}-{base,stable}
py311-{lowest}
project

[testenv]
Expand All @@ -16,7 +16,10 @@ deps =
-e .[tests]
stable: -r stable-requirements.txt
lowest: sqlalchemy<2
lowest: psycopg2-binary
commands =
lowest: pip uninstall -y psycopg psycopg-binary
stable: pip uninstall -y psycopg psycopg-binary
pip --version
# Output installed versions to compare with previous test runs in case a dependency's change
# breaks things for our build.
Expand All @@ -36,7 +39,7 @@ commands =


[testenv:project]
basepython = python3.10
basepython = python3.11
skip_install = true
usedevelop = false
deps =
Expand Down

0 comments on commit 0139bea

Please sign in to comment.