blob: 1d2e86ba18f316f3d45c7598f2daaea4719c6be1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
|