From 439022f058cb2b9bbf6e2b46c067f4c828a1cab0 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Thu, 25 Nov 2021 03:25:44 +0000 Subject: Initial commit --- base.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 base.py (limited to 'base.py') diff --git a/base.py b/base.py new file mode 100644 index 0000000..1d2e86b --- /dev/null +++ b/base.py @@ -0,0 +1,23 @@ +from peewee import MySQLDatabase, Model +import yaml + + +with open("config.yaml", "r") as yamlfile: + config = yaml.load(yamlfile, Loader=yaml.CLoader) + print("Read config successful") + config = config + + +db_conf = config["database"] +db = MySQLDatabase( + db_conf["name"], + user=db_conf["username"], + password=db_conf["password"], + host=db_conf["host"], +) +db.connect() + + +class BaseModel(Model): + class Meta: + database = db -- cgit v1.2.3