I am writing a pyqt5 qui that interfaces with my psql DB via SQslDatabase. External-to-me processes have a listen/notify setup to communicate status to other components via the database. So, my gui needs to listen, as well as send notifications. I setup listeners successfully with QSqlDriver (QSqlDriver.subscribeToNotification() func and QSqlDriver.notification() event) as described here, but is there a way of sending notifications on a specified channel with a specified payload?
My current workaround is doing this via a direct DB query. Here's a stripped down version of the code:
db = QSqlDatabase.addDatabase('QPSQL') #DB connection setup elsewhere in the code
query = QSqlQuery(db)
query_str = "NOTIFY some_channel, 'some payload';"
query.exec_(query_str)
My listener catches this successfully. But since the driver provides a function for listening to notify messages, I'm wondering if there is a function call for sending messages too.