MCPcopy Index your code
hub / github.com/HelloZeroNet/ZeroNet / actionChartDbQuery

Method actionChartDbQuery

plugins/Chart/ChartPlugin.py:33–49  ·  view source on GitHub ↗
(self, to, query, params=None)

Source from the content-addressed store, hash-verified

31class UiWebsocketPlugin(object):
32 @flag.admin
33 def actionChartDbQuery(self, to, query, params=None):
34 if config.debug or config.verbose:
35 s = time.time()
36 rows = []
37 try:
38 if not query.strip().upper().startswith("SELECT"):
39 raise Exception("Only SELECT query supported")
40 res = db.execute(query, params)
41 except Exception as err: # Response the error to client
42 self.log.error("ChartDbQuery error: %s" % err)
43 return {"error": str(err)}
44 # Convert result to dict
45 for row in res:
46 rows.append(dict(row))
47 if config.verbose and time.time() - s > 0.1: # Log slow query
48 self.log.debug("Slow query: %s (%.3fs)" % (query, time.time() - s))
49 return rows
50
51 @flag.admin
52 def actionChartGetPeerLocations(self, to):

Callers

nothing calls this directly

Calls 2

errorMethod · 0.80
executeMethod · 0.45

Tested by

no test coverage detected