-
Notifications
You must be signed in to change notification settings - Fork 0
/
db_config.py
25 lines (21 loc) · 998 Bytes
/
db_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
def db_config_html(environ):
DB_CONFIG = {}
DB_CONFIG["ENGINE"] = environ.get("DB_ENGINE", "")
DB_CONFIG["HOSTNAME"] = environ.get("DB_HOSTNAME", "")
DB_CONFIG["PORT"] = environ.get("DB_PORT", "")
DB_CONFIG["NAME"] = environ.get("DB_NAME", "")
DB_CONFIG["USERNAME"] = environ.get("DB_USERNAME", "")[1:-1]
DB_CONFIG["PASSWORD"] = environ.get("DB_PASSWORD", "")[1:-1]
if DB_CONFIG["ENGINE"] == "mysql":
DB_CONFIG["DIALECT_DRIVER"] = "mysql+pymysql"
elif DB_CONFIG["ENGINE"] == "postgresql":
DB_CONFIG["DIALECT_DRIVER"] = "???"
else:
DB_CONFIG["DIALECT_DRIVER"] = "???"
DB_CONFIG["URI"] = DB_CONFIG["DIALECT_DRIVER"] + '://' + DB_CONFIG["USERNAME"] + ':' + DB_CONFIG["PASSWORD"] + '@' + DB_CONFIG["HOSTNAME"] + ':' + DB_CONFIG["PORT"] + '/' + DB_CONFIG["NAME"]
html = "DB_CONFIG <br/> \n"
html += "--------- <br/> \n"
for DB_VAR in DB_CONFIG.keys():
html += DB_VAR + ": " + DB_CONFIG[DB_VAR] + " <br/> \n"
html += "<br/> \n"
return html