From 5d6668fda42ed9e8ed051e00fb0b64504aa23971 Mon Sep 17 00:00:00 2001 From: jwansek Date: Sat, 7 Oct 2023 00:11:46 +0100 Subject: Made the database hhost be in the config file --- database.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'database.py') diff --git a/database.py b/database.py index 23e06f0..846da4d 100644 --- a/database.py +++ b/database.py @@ -4,7 +4,7 @@ import os @dataclass class PowerDatabase: - host: str = "db" + host: str = None user: str = "root" passwd: str = None db: str = "power" @@ -13,6 +13,9 @@ class PowerDatabase: def __enter__(self): if self.passwd is None: self.passwd = os.environ["MYSQL_ROOT_PASSWORD"] + + if self.host is None: + self.host = os.environ["MYSQL_HOST"] try: self.__connection = self.__get_connection() @@ -112,7 +115,7 @@ if __name__ == "__main__": dotenv.load_dotenv(dotenv_path = "db.env") host = "srv.athome" else: - host = "db" + host = None with PowerDatabase(host = host) as db: print(db.get_tasmota_devices()) -- cgit v1.2.3