sql row factory

This commit is contained in:
2019-03-11 07:51:05 +01:00
parent fa152f4d46
commit e3eaba33ed
5 changed files with 20 additions and 5 deletions

View File

@@ -31,11 +31,12 @@ class handler(asyncTornado.asyncRequestHandler):
raise Exception("Missing required arguments")
method = args_filter[0]
method_value = self.request.arguments[method]
method_value = self.get_argument(method)
cur = glob.sql.cursor()
conn = glob.new_sql()
cur = conn.cursor()
sql = SQL_STRUCT["main"] % SQL_STRUCT["method"]
sql = SQL_STRUCT["main"] % SQL_STRUCT[method]
if method == "timestamp":
sql = sql % method_value
else:
@@ -45,12 +46,14 @@ class handler(asyncTornado.asyncRequestHandler):
data = cur.fetchone()
cur.close()
conn.close()
status_code = 200
except Exception as e:
status_code = 400
data["status"] = status_code
data["message"] = str(e)
print("Err: %s" % e)
finally:
self.write( json.dumps(data) )
self.set_header("Content-Type", "application/json")