Quickstart
Start a throwaway server on port 3307, with its data in /tmp/asql-demo:
aios --root /tmp/asql-demo exec "compute serve sql=1 mysql_port=3307"
With no user configured, it listens on 127.0.0.1 only and any local client gets in, under any name, as admin. Set a main login before using it on a shared machine; see Users, tokens and TLS.
In another terminal, create a table and query it:
aios-asql-console -P 3307
CREATE DATABASE store;
USE store;
CREATE TABLE lines (id INT PRIMARY KEY AUTO_INCREMENT, orderno INT, qty INT, picked INT);
INSERT INTO lines (orderno, qty, picked) VALUES (1001, 2, 0), (1001, 1, 1), (1002, 5, 5);
SELECT orderno, SUM(qty) AS qty, SUM(picked) AS picked FROM lines GROUP BY orderno;
Now keep that result current with a Thing:
CREATE THING order_totals KEY orderno READS lines
AS SELECT orderno, COUNT(*) AS line_count, SUM(qty) AS qty, SUM(picked) AS picked
FROM lines GROUP BY orderno;
UPDATE lines SET picked = 2 WHERE orderno = 1001 AND qty = 2;
SHOW THING order_totals; -- order 1001 now shows picked = 3
SHOW THING HISTORY order_totals '1001'; -- what changed it, before and after
The UPDATE recomputed order 1001 only. SHOW THING reads the stored result; it does not run the query.
Stop the server with Ctrl-C. Start it again with the same command and the data is still there.
Next: Things, or mirror a MariaDB database.
