-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsql.py
More file actions
20 lines (17 loc) · 797 Bytes
/
sql.py
File metadata and controls
20 lines (17 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class ExecSql:
"""
Class to store all the sql statements to be executed
in rgate
"""
CreateRgateTable = """CREATE TABLE IF NOT EXISTS "rgate" (
"reqid" INTEGER,
"status_code" INTEGER,
"time_elapsed" INTEGER,
PRIMARY KEY("reqid" AUTOINCREMENT)
);"""
InsertRequestStats = """INSERT INTO rgate(status_code, time_elapsed) VALUES(?, ?);"""
NthPercentileQuery = """WITH p AS (SELECT time_elapsed, NTILE(?) OVER (ORDER BY time_elapsed) AS percentile
FROM rgate
WHERE status_code = 200)
SELECT percentile, max(time_elapsed) as lat FROM p;"""
StatsQuery = """SELECT Count(*) AS total_queries, Count(CASE WHEN status_code = 200 THEN 1 ELSE NULL END) AS success_rate, Avg(time_elapsed) as avg_time FROM rgate;"""