diff options
author | Lukas Metzger | 2020-05-28 14:28:43 +0200 |
---|---|---|
committer | Lukas Metzger | 2020-05-28 14:28:43 +0200 |
commit | 0647156ed167449546f529ca354cf1c3282a698e (patch) | |
tree | 6ebc683b3b72263979e6ce9d14e768a524326c47 | |
parent | Added deployment features (diff) | |
download | bwlp-statistics-0647156ed167449546f529ca354cf1c3282a698e.tar.gz bwlp-statistics-0647156ed167449546f529ca354cf1c3282a698e.tar.xz bwlp-statistics-0647156ed167449546f529ca354cf1c3282a698e.zip |
Read config from file
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | db.py | 6 |
2 files changed, 6 insertions, 1 deletions
@@ -1 +1,2 @@ __pycache__ +config.ini @@ -1,9 +1,13 @@ #!/usr/bin/env python3 import pymysql +import configparser + +c = configparser.ConfigParser() +c.read('config.ini') def getConnection(): - db = pymysql.connect('mysql.oebsrv.int.intranet', 'bwlehrpool', 'weav3Nu8ShaifaePh6aiqu6aetei7e', 'bwlehrpool', cursorclass=pymysql.cursors.DictCursor) + db = pymysql.connect(c.get('db', 'host'), c.get('db', 'username'), c.get('db', 'password'), c.get('db', 'name'), cursorclass=pymysql.cursors.DictCursor) return db def closeConnection(db): |