sql row factory
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user