Serverless ClickHouse URL Engine
π Ready? Get your own table in zero minutes β±οΈ
You're about to create your very own serverless, storage persistent URL Engine table - fast, free and always 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.
Choose a unique URL path
We will use the ClickHouse URL Engine to query data to/from our service.
- Open your ClickHouse client
- Choose your unique URL path
Replace
mY5uPeRs3Cre7tok3N
with your Token!
To avoid typing this every time, we'll store our URL as a variable
:) SET param_url = 'https://urleng.com/mY5uPeRs3Cre7tok3N'
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 gets read each time.
:) 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/mY5uPeRs3Cre7tok3N', '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
No server? Get your table data in/out of your table using clickhouse-local
clickhouse-local -q "select count() from url('https://urleng.com/mY5uPeRs3Cre7tok3N', 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/mY5uPeRs3Cre7tok3N-H 'Content-Type:application/x-ndjson' --data-binary @ndjson.txt
POST json
curl -X POST https://url-engine.metrico.in/mY5uPeRs3Cre7tok3N-H 'Content-Type: application/json' -d '[{"key":"curl","value":1}]'
GET json
curl -X GET https://urleng.com/mY5uPeRs3Cre7tok3N
That's it
Enjoy your free, bottomless URL table! Use it to share small datasets, states, k/vs and anything you can think of between your nodes as if they were a distributed cluster.
π¬ Found a problem? Got some feedback or ideas? Please open an Issue or start a Discussion in our community
π¨π¨π¨
π¨π¨π¨
π₯π¨π¨