Skip to content

Commit

Permalink
adds option to select psycopg version
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Konoval committed Aug 10, 2024
1 parent 0ebebd5 commit 3ef2050
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@ be added to the app's database via the usual django ``migrate`` command.
We should also add ``pgpubsub`` and ``pgtrigger`` into ``INSTALLED_APPS``.
If we wish to run the ``pgpubsub`` tests, we need to add
``pgpubsub.tests`` into ``INSTALLED_APPS`` too.

``pgpubsub`` is compatible with both ``psycopg2`` and ``psycopg``. Install the
version you prefer and ``pgpubsub`` will use it. If both are installed
``psycopg2`` is prefered in order to be compatible with the previous
``pgpubsub`` versions. Set environment variable
``PGPUBSUB_USE_PSYCOPG_V3=True`` to override and force ``psycopg`` version 3
usage.
4 changes: 4 additions & 0 deletions pgpubsub/compatibility.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import os

try:
if os.getenv('PGPUBSUB_USE_PSYCOPG_V3', 'False') == 'True':
raise ImportError()

from psycopg2._psycopg import Notify

class ConnectionWrapper:
Expand Down

0 comments on commit 3ef2050

Please sign in to comment.