Sqlite
From Leo's Notes
This page was last edited on 3 July 2020, at 05:47.
Quick Usage
Run sqlite3. Use .tables to show tables.
Create a table
create table bandwidth (
mac character(12),
time datetime,
tx_bytes unsigned int,
rx_bytes unsigned int
);
Create a composite key
CREATE UNIQUE INDEX pk_index ON "bandwidth" ("mac", "time");
Find the current hour as a timestamp, which you can insert as a datetime field?
select strftime('%s', 'now') - (strftime('%s','now')%3600);
To insert a record:
insert into bandwidth ('mac', 'time', 'tx_bytes', 'rx_bytes')
VALUES ('000c2958db2f', strftime('%s', 'now') - (strftime('%s','now')%3600), 100, 100);