summaryrefslogtreecommitdiff
path: root/jfr_playoff/db.py
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2018-02-25 11:17:24 +0100
committeremkael <emkael@tlen.pl>2018-02-25 11:17:24 +0100
commita8aa671f49152dc7975de9bd62b929aab0ff309b (patch)
tree642dca7069a98644e54d526d8255a2ac7364cbff /jfr_playoff/db.py
parent70a74524095166ee349603e2d48f2cf7c6c5f118 (diff)
parent8c500a75a6eafd65b332d0f8346d9059d5293cbb (diff)
Merge branch 'verbose_logging' into devel
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))