fix convert query results

This commit is contained in:
ksyasuda 2022-10-20 21:32:45 -07:00
parent da656d9582
commit 670f77722f
2 changed files with 7 additions and 2 deletions

View File

@ -22,10 +22,15 @@ logger.addHandler(handler)
def convert_query_result(query_res): def convert_query_result(query_res):
"""Return List(elements) from query result List(Tuples(element)).""" """Return List(elements) from query result List(Tuples(element))."""
logger.debug("Converting %s", query_res)
if len(query_res) == 0: if len(query_res) == 0:
logger.warning("Received empty result set from DB") logger.warning("Received empty result set from DB")
return [] return []
return [list(i) for i in query_res] if len(query_res) > 1 else query_res[0][0] if len(query_res) == 1:
res = list(query_res[0])
else:
res = [list(row) for row in query_res]
return res
class DbWrapper: class DbWrapper:

View File

@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project] [project]
name = "pydb" name = "pydb"
version = "0.0.1" version = "0.0.3"
authors = [ authors = [
{ name="Kyle Yasuda", email="suda@sudacode.com" }, { name="Kyle Yasuda", email="suda@sudacode.com" },
] ]