Coverage for app/models/__init__.py: 93%

14 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2024-09-05 21:26 +0000

1from peewee import * # import all so we don't have to import in each model file 

2import os 

3 

4# from app import login 

5from app import app 

6 

7def getMySQLDB(): 

8 if os.environ.get("USING_CONTAINER", False): 

9 app.config['db']['host'] = 'db' 

10 else: 

11 app.config["db"]["host"] = "localhost" 

12 db_cfg = app.config['db'] 

13 theDB = MySQLDatabase(db_cfg['name'], host = db_cfg['host'], user = db_cfg['username'], passwd = db_cfg['password']) 

14 return theDB 

15 

16mainDB = getMySQLDB() # MySQL (current) 

17 

18class baseModel(Model): 

19 class Meta: 

20 database = mainDB