summaryrefslogtreecommitdiff
path: root/mqtt_client/database.py
diff options
context:
space:
mode:
authorLuiz Gustavo Monteiro <luizgu_mreis@hotmail.com>2025-10-26 16:09:12 -0300
committerLuiz Gustavo Monteiro <luizgu_mreis@hotmail.com>2025-10-26 16:09:12 -0300
commit52a4fe2625b63683fcdcd74f704e49aa65cb0dd8 (patch)
tree642dde8a39aefa58df55821b9bf84251defc4bcf /mqtt_client/database.py
parente9f3d47100fd5f61342af0a6f8e1abbe3bea9093 (diff)
database connection tested successfully - tables readed on pgadmin
Diffstat (limited to 'mqtt_client/database.py')
-rw-r--r--mqtt_client/database.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/mqtt_client/database.py b/mqtt_client/database.py
index e69de29..c0691a1 100644
--- a/mqtt_client/database.py
+++ b/mqtt_client/database.py
@@ -0,0 +1,10 @@
+from sqlalchemy import create_engine
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import sessionmaker
+import os
+
+DATABASE_URL = os.getenv("DATABASE_URL", "postgresql://root:public@postgres:5432/control_station")
+
+engine = create_engine(DATABASE_URL)
+SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
+Base = declarative_base()