summaryrefslogtreecommitdiff
path: root/jfr_playoff/db.py
diff options
context:
space:
mode:
Diffstat (limited to 'jfr_playoff/db.py')
-rw-r--r--jfr_playoff/db.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/jfr_playoff/db.py b/jfr_playoff/db.py
index 71f3dcb..bca05d2 100644
--- a/jfr_playoff/db.py
+++ b/jfr_playoff/db.py
@@ -1,9 +1,12 @@
import sys
+from jfr_playoff.logger import PlayoffLogger
+
+
class PlayoffDB(object):
db_cursor = None
- DATABASE_NOT_CONFIGURED_WARNING = 'WARNING: database not configured'
+ DATABASE_NOT_CONFIGURED_WARNING = 'database not configured'
def __init__(self, settings):
reload(sys)
@@ -14,12 +17,14 @@ class PlayoffDB(object):
password=settings['pass'],
host=settings['host'],
port=settings['port'])
+ PlayoffLogger.get('db').info('db settings: %s', settings)
self.db_cursor = self.database.cursor(buffered=True)
def get_cursor(self):
return self.db_cursor
def __execute_query(self, db_name, sql, params):
+ PlayoffLogger.get('db').info('query (%s): %s %s', db_name, sql.replace('\n', ' '), params)
self.db_cursor.execute(sql.replace('#db#', db_name), params)
def fetch(self, db_name, sql, params):
@@ -29,6 +34,7 @@ class PlayoffDB(object):
row = self.db_cursor.fetchone()
return row
except mysql.connector.Error as e:
+ PlayoffLogger.get('db').error(str(e))
raise IOError(e.errno, str(e), db_name)
def fetch_all(self, db_name, sql, params):
@@ -38,6 +44,7 @@ class PlayoffDB(object):
results = self.db_cursor.fetchall()
return results
except mysql.connector.Error as e:
+ PlayoffLogger.get('db').error(str(e))
raise IOError(
message=str(e), filename=db_name,
errno=e.errno, strerror=str(e))