diff options
author | emkael <emkael@tlen.pl> | 2017-07-31 19:44:32 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2017-07-31 19:44:32 +0200 |
commit | 13d8dbb4135f290a80577f6fca09d9488e861a18 (patch) | |
tree | 0e578f113cdbfd60439ad7aace75452554182a16 /playoff | |
parent | 87e073ad5ef220259294182f0cbf74051a1742ef (diff) |
Factoring out DB operations
Diffstat (limited to 'playoff')
-rw-r--r-- | playoff/db.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/playoff/db.py b/playoff/db.py new file mode 100644 index 0000000..aa0c2e2 --- /dev/null +++ b/playoff/db.py @@ -0,0 +1,19 @@ +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 fetch(self, db, sql, params): + self.db_cursor.execute(sql.replace('#db#', db), params) + row = self.db_cursor.fetchone() + return row |