Psycopg in my project

Hello Community,

I have the following question:

I use in my Plone 5 project the psycopg 2.9.1 library I want to use only the listen function of my PosgreSQL. I have tested it and it seems to work. But in the Zope documentation it says that you should use ZPsycopgDA.

What I don't understand now is why psycopg 2.9.1 works anyway.


cursor = connection.cursor()
cursor.execute("LISTEN channelxyz;")

I would like to "listen" to the listeners and process them further.

What I have stored in the database is from another system, I just want to wait for updates from the database and output them in the UI.

Several clients use psycopg (2) without ZPsycopgDA in Zope applications. Thus, this is possible. The ZPsycopgDA makes a Postgres connection available as a Zope "database adapter" object -- an object in the Zope object hierarchy configurable via the ZMI (the Zope Management Interface). In the early days of Zope, this was important: Zope applications were mostly created via the 'ZMI. Nowadays, Zope applications live mostly in Python code, managed in a code repository; the ZMI(andZPsycopgDA`) has lost much of its importance.

Keep in mind however, that Zope is a multi-task transactional system. It is likely that you want an integration of Postgres in Zope's transaction system and avoid that current threads use the same Postgres connection.