I have a PostgreSQL DB that updates periodically, and want to publish the latest changes to a mosquitto broker. What is the most elegant way to do this approach ?
Ok this idea is interesting i am using PostgreSQL 9.5 and in the console if i type CREATE LANGUAGE plpythonu; the python language is available. But how i can receive the whole database and the periodically changes of the database into my Broker.
CREATE FUNCTION publishChanges ()
RETURNS integer
AS $$
import paho.mqtt.client as mqtt
import paho.mqtt.publish as publish
#client = mqtt.Client()
#client.connect("localhost", 1883, 60)
publish.single("test/data", SELECT * from table ,hostname="127.0.0.1")
#client.loop_forever()
$$ LANGUAGE plpythonu;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With