diff options
author | emkael <emkael@tlen.pl> | 2017-10-02 23:48:02 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2017-10-02 23:48:02 +0200 |
commit | 19caef32a560a4a797fba4ab2fa93bc2b410039b (patch) | |
tree | 6b965e9e3320305517929d4792ec1948c51ec2a4 /jfr_playoff/db.py | |
parent | 86654dee683d9a2cda00a528b006433cebeebf26 (diff) | |
parent | 40d09a61727d3c960a816def07fb319853a90116 (diff) |
Merge branch 'refactor'
Diffstat (limited to 'jfr_playoff/db.py')
-rw-r--r-- | jfr_playoff/db.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/jfr_playoff/db.py b/jfr_playoff/db.py new file mode 100644 index 0000000..b94f3d5 --- /dev/null +++ b/jfr_playoff/db.py @@ -0,0 +1,22 @@ +import mysql.connector + + +class PlayoffDB(object): + + db_cursor = None + + def __init__(self, settings): + self.database = mysql.connector.connect( + user=settings['user'], + password=settings['pass'], + host=settings['host'], + port=settings['port']) + self.db_cursor = self.database.cursor(buffered=True) + + def get_cursor(self): + return self.db_cursor + + def fetch(self, db_name, sql, params): + self.db_cursor.execute(sql.replace('#db#', db_name), params) + row = self.db_cursor.fetchone() + return row |