Log query timing in src/Database.py in 1 line, not 2

This commit is contained in:
jesopo 2018-11-14 23:04:54 +00:00
parent 06078ba959
commit 1ec6d0ad40

View file

@ -307,8 +307,6 @@ class Database(object):
fetch_func: typing.Callable[[sqlite3.Cursor], typing.Any], fetch_func: typing.Callable[[sqlite3.Cursor], typing.Any],
params: typing.List=[]): params: typing.List=[]):
printable_query = " ".join(query.split()) printable_query = " ".join(query.split())
self.log.trace("executing query: \"%s\" (params: %s)",
[printable_query, params])
start = time.monotonic() start = time.monotonic()
cursor = self.cursor() cursor = self.cursor()
@ -318,7 +316,8 @@ class Database(object):
end = time.monotonic() end = time.monotonic()
total_milliseconds = (end - start) * 1000 total_milliseconds = (end - start) * 1000
self.log.trace("executed in %fms", [total_milliseconds]) self.log.trace("executed query in %fms: \"%s\" (params: %s)",
[total_millisecons, printable_query, params])
return value return value
def execute_fetchall(self, query: str, params: typing.List=[]): def execute_fetchall(self, query: str, params: typing.List=[]):