diff --git a/docs/installation.rst b/docs/installation.rst index 3990aae..a117612 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -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. diff --git a/pgpubsub/compatibility.py b/pgpubsub/compatibility.py index 047ec47..902723b 100644 --- a/pgpubsub/compatibility.py +++ b/pgpubsub/compatibility.py @@ -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: