31 lines
850 B
Python
31 lines
850 B
Python
import os
|
|
import json
|
|
from peewee import MySQLDatabase
|
|
|
|
|
|
PLATFORM = os.environ.get("PLATFORM", "vm") # or dci
|
|
|
|
DB_ENGINE = os.environ.get("DB_ENGINE", "mysql")
|
|
DB_HOST = os.environ.get("DB_HOST", "mysql")
|
|
DB_PORT = os.environ.get("DB_PORT", 3306)
|
|
DB_USER = os.environ.get("DB_USER", "root")
|
|
DB_PASSWORD = os.environ.get("DB_PASSWORD", None) # not secure!!!
|
|
DB_NAME = os.environ.get("DB_NAME", "isp") # or auth for dci
|
|
|
|
if DB_PASSWORD is None:
|
|
with open('config.json', 'r') as f:
|
|
platform_config = json.load(f)
|
|
DB_PASSWORD = platform_config.get("MysqlRootPassword")
|
|
|
|
database = MySQLDatabase(
|
|
DB_NAME, **{
|
|
'charset': 'utf8',
|
|
'sql_mode': 'PIPES_AS_CONCAT',
|
|
'use_unicode': True,
|
|
'host': DB_HOST,
|
|
'port': DB_PORT,
|
|
'user': DB_USER,
|
|
'password': DB_PASSWORD
|
|
}
|
|
)
|