pgnotify
pgnotify copied to clipboard
Add notify method
This patch adds a method for sending a PostgreSQL notify with a payload to a specific channel.
Thank you kindly for this PR! Definitely a much-needed addition to this library.
Some things will need changing before we merge:
- The current implementation is vulnerable to SQL injection (as mentioned by @madsmtm)
- The cursor needs proper cleanup (probably with a
withas per http://initd.org/psycopg/docs/usage.html) - As the docs and @prankymat mention, the
pg_notify(function is probably nicer than the keyword style so let's change to that. - I'd rather the tests did a real test with a temporary database rather than mocking (this isn't essential, so we can probably change this in the future/a separate PR/whatever).