|
236 | 236 |
|
237 | 237 | #define DELETE_SYSTEM_TABLE "DELETE FROM RebootEvent" |
238 | 238 |
|
239 | | -//This statement is a static version of what the .dump command does. A dynamic |
240 | | -//version would query the master table to get tables and then PRAGMA to get |
241 | | -//rows. The actualy query is simpler than it looks. It seems SQLite supports |
242 | | -//prepending/appending random text to the result of a query, and that is what we |
243 | | -//do here. quote() gives a quoted string of the row content, suitable for |
244 | | -//inclusion in another SQL query. The || is string concation. So, the query |
245 | | -//queries for all columns, and each row is prefixed with some string |
246 | | -#define DUMP_EVENTS "SELECT \"INSERT IGNORE INTO NetworkEvent"\ |
247 | | - "(NodeId,BootCount,BootMultiplier,Timestamp,"\ |
248 | | - "Sequence,L3SessionId,L4SessionId,DeviceId,"\ |
249 | | - "DeviceTypeId,NetworkAddress,NetworkAddressFamily,"\ |
250 | | - "EventType,EventParam,EventValue) "\ |
251 | | - "VALUES(\" "\ |
252 | | - "|| quote(\"NodeId\"), quote(\"SessionId\"),"\ |
253 | | - "quote(\"SessionIdMultip\"),quote(\"Timestamp\"), "\ |
254 | | - "quote(\"Sequence\"), quote(\"L3SessionId\"), "\ |
255 | | - "quote(\"L4SessionId\"), quote(\"InterfaceId\"), "\ |
256 | | - "quote(\"InterfaceType\"), quote(\"NetworkAddress\"), "\ |
257 | | - "quote(\"NetworkAddressFamily\"), quote(\"EventType\"), "\ |
258 | | - "quote(\"EventParam\"), quote(\"EventValue\") "\ |
259 | | - "|| \")\" FROM \"NetworkEvent\" WHERE Timestamp>=? ORDER BY Timestamp;" |
260 | | - |
261 | | -#define DUMP_UPDATES "SELECT \"REPLACE INTO NetworkUpdate"\ |
262 | | - "(NodeId,BootCount,BootMultiplier,L3SessionId,"\ |
263 | | - "L4SessionId,DeviceId,NetworkAddress,DeviceTypeId,"\ |
264 | | - "Timestamp,Sequence,EventValueStr,"\ |
265 | | - "ServerTimestamp) VALUES(\" ||"\ |
266 | | - "quote(\"NodeId\"), quote(\"SessionId\"),"\ |
267 | | - "quote(\"SessionIdMultip\"), quote(\"L3SessionId\"),"\ |
268 | | - "quote(\"L4SessionId\"), quote(\"InterfaceId\"),"\ |
269 | | - "quote(\"NetworkAddress\"), quote(\"InterfaceType\"),"\ |
270 | | - "quote(\"Timestamp\"), quote(\"Sequence\"), "\ |
271 | | - "quote(\"EventValueStr\") ||"\ |
272 | | - "\", Now())\" FROM \"NetworkUpdates\" WHERE "\ |
273 | | - "Timestamp>=? ORDER BY Timestamp;" |
274 | | - |
275 | | -#define DUMP_GPS "SELECT \"REPLACE INTO GpsUpdates" \ |
276 | | - "(NodeId,BootCount,BootMultiplier"\ |
277 | | - ",Timestamp,Sequence,Latitude,Longitude" \ |
278 | | - ",Altitude,Speed,SatelliteCount) VALUES(\" "\ |
279 | | - "|| quote(\"NodeId\"), quote(\"BootCount\"), "\ |
280 | | - "quote(\"BootMultiplier\"), quote(\"Timestamp\"), "\ |
281 | | - "quote(\"Sequence\"), quote(\"Latitude\"), "\ |
282 | | - "quote(\"Longitude\"), quote(\"Altitude\"), "\ |
283 | | - "quote(\"Speed\"), quote(\"SatelliteCount\") "\ |
284 | | - "|| \")\" FROM \"GpsUpdate\" ORDER BY Timestamp;" |
285 | | - |
286 | | -#define DUMP_MONITOR "SELECT \"REPLACE INTO MonitorEvents" \ |
287 | | - "(NodeId,Timestamp,Sequence,Boottime) VALUES(\" "\ |
288 | | - "|| quote(\"NodeId\"), quote(\"Timestamp\"), "\ |
289 | | - "quote(\"Sequence\"), quote(\"Boottime\") "\ |
290 | | - "|| \")\" FROM \"MonitorEvents\" ORDER BY Timestamp;" |
291 | | - |
292 | | -#define DUMP_USAGE "SELECT \"INSERT INTO DataUse" \ |
293 | | - "(DeviceId,SimCardIccid,SimCardImsi,Timestamp,RxData,TxData) VALUES(\" "\ |
294 | | - "|| quote(\"DeviceId\"), quote(\"SimCardIccid\"), " \ |
295 | | - "quote(\"SimCardImsi\") || \",FROM_UNIXTIME(\" "\ |
296 | | - "|| quote(\"Timestamp\") || \"),\" || "\ |
297 | | - "quote(\"RxData\"), quote(\"TxData\") "\ |
298 | | - "|| \") ON DUPLICATE KEY UPDATE RxData=RxData+\"" \ |
299 | | - "|| quote(\"RxData\") || \", TxData=TxData+\"" \ |
300 | | - "|| quote(\"TxData\") FROM \"DataUse\";" |
301 | | - |
302 | 239 | //Define statements for JSON export |
303 | 240 | #define DUMP_EVENTS_JSON "SELECT * FROM NetworkEvent WHERE Timestamp>=? ORDER BY TimeStamp" |
304 | 241 |
|
|
0 commit comments