diff options
-rw-r--r-- | wqflask/dbFunction/webqtlDatabaseFunction.py | 7 | ||||
-rw-r--r-- | wqflask/utility/logger.py | 8 |
2 files changed, 9 insertions, 6 deletions
diff --git a/wqflask/dbFunction/webqtlDatabaseFunction.py b/wqflask/dbFunction/webqtlDatabaseFunction.py index d7e160d0..4a0fb40f 100644 --- a/wqflask/dbFunction/webqtlDatabaseFunction.py +++ b/wqflask/dbFunction/webqtlDatabaseFunction.py @@ -47,7 +47,7 @@ def getCursor(): except: return None -def fetchone(callername,query): +def fetchone(query): """Return tuple containing one row by calling SQL directly """ @@ -55,6 +55,7 @@ def fetchone(callername,query): def helper(query): res = g.db.execute(query) return res.fetchone() + callername = stack()[1][3] return logger.sql(callername, query, helper) def gn_server(path): @@ -73,10 +74,10 @@ def retrieve_species(group): """ if USE_GN_SERVER: - result = gn_server("/cross/"+group) + result = gn_server("/cross/"+group+".json") return result["species"] else: - result = fetchone(stack()[0][3],"select Species.Name from Species, InbredSet where InbredSet.Name = '%s' and InbredSet.SpeciesId = Species.Id" % (group)) + result = fetchone("select Species.Name from Species, InbredSet where InbredSet.Name = '%s' and InbredSet.SpeciesId = Species.Id" % (group)) return result[0] ########################################################################### diff --git a/wqflask/utility/logger.py b/wqflask/utility/logger.py index 6a8b3e7e..d56b134c 100644 --- a/wqflask/utility/logger.py +++ b/wqflask/utility/logger.py @@ -29,7 +29,7 @@ import logging import string from inspect import isfunction -from utility.tools import LOG_LEVEL +from utility.tools import LOG_LEVEL, LOG_SQL class GNLogger: """A logger class with some additional functionality, such as @@ -76,10 +76,12 @@ class GNLogger: def sql(self, description, sqlcommand, fun = None): """Log SQL command, optionally invoking a timed fun""" - self.info(description,sqlcommand) + if LOG_SQL: + self.info(description,sqlcommand) if fun: result = fun(sqlcommand) - self.info("result:",result) + if LOG_SQL: + self.debug(result) return result def collect(self,fun,*args): |