insert json from mqtt into postgresql
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 3 Aug 2017 10:51:48 +0000 (12:51 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 3 Aug 2017 10:51:48 +0000 (12:51 +0200)
mqtt-pgsql.sh [new file with mode: 0755]

diff --git a/mqtt-pgsql.sh b/mqtt-pgsql.sh
new file mode 100755 (executable)
index 0000000..c0d56fa
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh -xe
+
+mosquitto_sub -h 10.13.37.5 -t rpi2/rtl433/json | while read json ; do
+       echo $json > /dev/shm/rtl433.json
+       psql -c "copy rtl433 (json) from '/dev/shm/rtl433.json'" rot13
+done