diff options
| author | Gustavoeklund01 <eklundgu@gmail.com> | 2025-10-27 19:16:14 -0300 |
|---|---|---|
| committer | Gustavoeklund01 <eklundgu@gmail.com> | 2025-10-27 19:16:14 -0300 |
| commit | be7952f3585fe895a3309a19e14cd93f89c3ce1b (patch) | |
| tree | a5fc0ee9f964273879abcd6a17b96ac44eec9941 /mqtt_client/main.py | |
| parent | 4008253dfd2005da102f6da06389268ecef152f6 (diff) | |
| parent | 52a4fe2625b63683fcdcd74f704e49aa65cb0dd8 (diff) | |
Merge branch 'master' of https://github.com/Simplesmente-O-Grupo/iot-monitoring
Diffstat (limited to 'mqtt_client/main.py')
| -rw-r--r-- | mqtt_client/main.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/mqtt_client/main.py b/mqtt_client/main.py index dad09b5..109ca49 100644 --- a/mqtt_client/main.py +++ b/mqtt_client/main.py @@ -2,8 +2,15 @@ import paho.mqtt.client as mqtt from paho.mqtt.enums import MQTTProtocolVersion import json from time import sleep +from database import engine +from models import Base import os +print("Creating ORM SQL Tables..") +Base.metadata.create_all(bind=engine) +print("Tables created successfully.") + + def on_connect(client, userdata, flags, reason_code, properties): print(f"Conectado: {reason_code}") # Me inscrevo em todos os tópicos sobre clima @@ -13,9 +20,9 @@ def on_connect(client, userdata, flags, reason_code, properties): def on_message(client, userdata, msg): payload = json.loads(msg.payload) print(msg.topic) - print(f"Value: {payload["value"]}") - print(f"Unit: {payload["unit"]}") - print(f"Timestamp: {payload["timestamp"]}") + print(f"Value: {payload['value']}") + print(f"Unit: {payload['unit']}") + print(f"Timestamp: {payload['timestamp']}") try: user_name = os.environ["MQTT_CLIENT_USER"] |
