Choose a unique URL path
You're about to create your very own serverless, storage persistent URL Engine table - accessible from anywhere.
Since there are no logins or signups, all data is hidden in public. The only protection is your own secret URL path.
Open your ClickHouse client and choose your URL path wisely - or just use this randomly generated example:
:) SET param_url = 'https://urleng.com/'
INSERT data
It's time to insert some data. The serverless table will
automatically adapt to the schema inserts.
:) INSERT INTO FUNCTION url({url:String}, JSONEachRow, 'key String, value UInt64') VALUES
('hello', 1)
SELECT data
Let's read our data back and apply some logic for fun.
Note due to how ClickHouse works, the full table is read.
:) SELECT * FROM url({url:String}, JSONEachRow)
CREATE URL Table
If you plan on using the data frequently, you can create a
persistent URL Engine table. Choose any schema, too.
:) CREATE TABLE default.url_engine_distributed
(
`key` String,
`value` UInt64,
)
ENGINE = URL('https://urleng.com/', 'JSONEachRow')
:) INSERT INTO url_engine_distributed VALUES
('hello', 1), ('world', 2)
:) SELECT * FROM url_engine_distributed
ββkeyβββ¬βvalueβ
β hello β 1 β
β world β 2 β
βββββββ΄ββββββ
2 rows in set. Elapsed: 0.185 sec.
EXPIRE/TTL Data
You can expire data by using or adding an __expires key/column with a future unix timestamp.
:) INSERT INTO FUNCTION url({url:String}, JSONEachRow, 'key String, value UInt64, __expires UInt64')
VALUES ('hello', 1, toUnixTimestamp(now()+300))
CLICKHOUSE Local
Get your table data into clickhouse-local with zero efforts
clickhouse-local -q "select count() from url('https://urleng.com/', JSONEachRow)"
CURL
Last but not least, data can be inserted and accessed through curl or any other HTTP GET/POST capable client.
# POST ndjson
curl -s -XPOST https://urleng.com/ -H 'Content-Type:application/x-ndjson' --data-binary @ndjson.txt
# POST json
curl -X POST https://url-engine.metrico.in/ -H 'Content-Type: application/json' -d '[{"key":"curl","value":1}]'
# GET json
curl -X GET https://urleng.com/