Database Reference
In-Depth Information
FROM dashboard.records_per_minute
ORDER BY 1''')),
ConsoleData(
[
{'label': 'Minute', 'type': 'number'},
{'label': 'Screen On', 'type': 'number'},
{'label': 'Charging', 'type': 'number'},
{'label': 'Half Charged', 'type': 'number'},
],
query=(
'''SELECT Minute, FracScreenOn, FracCharging,
FracHalfCharged
FROM dashboard.records_per_minute
ORDER BY 1''')),
ConsoleData(
[
{'label': 'Application', 'type': 'string'},
{'label': 'Users', 'type': 'number'},
],
table=('dashboard', 'top_apps')),
ConsoleData(
[
{'label': 'Zips In One Day', 'type': 'number'},
{'label': 'Num Device Days', 'type': 'number'},
],
table=('dashboard', 'zips_in_day')),
]
Note that the handler does not actually accept a table name or query in
the request. Instead it expects an index into a list defined in the file that
explicitly defines specific tables and queries. This avoids the issue of SQL
injection exploits or inadvertently exposing tables because the client is not
allowed to directly specify a query or table name. The list is constructed a bit
like our cached table definitions with a structure describing the data to be
supplied to the web client. One aspect that may seem a little odd is that we
use queries in this list despite having the ability to cache data. The reason is
that the queries in this list are designed to take advantage of the BigQuery
internal cache, so they do not add any overhead. This technique is covered
in Chapter 11.
Search WWH ::




Custom Search