summaryrefslogtreecommitdiff
path: root/jfr_playoff/db.py
diff options
context:
space:
mode:
authorMichaƂ Klichowicz <emkael@tlen.pl>2018-10-17 20:02:57 +0200
committerGitHub <noreply@github.com>2018-10-17 20:02:57 +0200
commit984540cd2dfba29c1dc9cbc43ab6fa4c85c7727b (patch)
treed03e49f564cec7c3eec7ce7c98fae530ec1544e0 /jfr_playoff/db.py
parent9a5f06ee9cddd38e11f49a2f934de202d34e63e2 (diff)
parent31fc51ce22e7c5197ed367cadd14d8a258f8fd65 (diff)
Merge pull request #28 from emkael/develv1.2.0
v1.2
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))