Skip to content

Commit b63f521

Browse files
committedMay 21, 2017
added logging
1 parent 71dea16 commit b63f521

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
 

‎cs50/sql.py

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import datetime
2+
import logging
23
import re
34
import sqlalchemy
45
import sys
@@ -16,6 +17,8 @@ def __init__(self, url, **kwargs):
1617
http://docs.sqlalchemy.org/en/latest/core/engines.html#sqlalchemy.create_engine
1718
http://docs.sqlalchemy.org/en/latest/dialects/index.html
1819
"""
20+
logging.basicConfig(level=logging.DEBUG)
21+
self.logger = logging.getLogger(__name__)
1922
try:
2023
self.engine = sqlalchemy.create_engine(url, **kwargs)
2124
except Exception as e:
@@ -109,6 +112,9 @@ def process(value):
109112
# execute statement
110113
result = self.engine.execute(statement)
111114

115+
# log statement
116+
self.logger.debug(statement)
117+
112118
# if SELECT (or INSERT with RETURNING), return result set as list of dict objects
113119
if re.search(r"^\s*SELECT\s+", statement, re.I):
114120
rows = result.fetchall()

0 commit comments

Comments
 (0)
Please sign in to comment.