Crack open the new Tableland CLI Shell

Crack open the new Tableland CLI Shell

Query tableland with a CLI shell

Crack open the new Tableland CLI Shell

Queries to Tableland in the command line are easier than ever with the new shell

By @Allen Muncy

TL;DR Today, we’re launching the Tableland interactive shell command. The Tableland shell command is built to be simple; just write SQL, we’ll handle the rest.

The Tableland CLI already enables developers to interact with Tableland through simple commands. From creating and writing to tables, to listing all the tables owed by a given address, to finding out the schema and information about a table, to much much more.

Today, we’re releasing a whole new feature: the interactive shell. The Tableland CLI shell command allows you to drop into an interactive shell, and just write SQL.

To give it a whirl, update to the latest version of our CLI: npm install -g @tableland/cli. Once this is done, you can run the tableland command.

Things like your preferred chain, key, and provider URL can be specified as flags to the shell command like so:

tableland shell --chain goerli --privayeKey 000...000 --providerUrl https://example.provider/

However, we’ve made life a little easier with another new CLI feature, the tableland init command! This new sub-command let’s you create Tableland “config” files, through which you can specify CLI options like your preferred default chain, your access/private keys (but be careful), your provider URL, and other things. See tableland --help for details.

So assuming you have a local config file setup in a project or directory on your machine, now, you can simply run tableland shell and you’ll see something like this:

Welcome to Tableland
Tableland CLI shell
Connected to goerli using 0xYourEthereumAddress

From here, you simply write SQL, and get back results. Just like you’d expect.

tableland> SELECT * FROM healthbot_5_1;
[ { counter: 4966 } ]
tableland> # Write more SQL!

It’s as simple as that. But wait, there’s more!

Since submitting mutating statements to the underlying chain does involve transaction costs, we’ve opted to have a confirmation message when your SQL would send a transaction to the chain (instead of something like a simple select/read). This is pretty handy as a double check before spending your previous tokens, but of course, like most CLI flags, you can turn this off if you want.

So now, if you submit a mutating transaction, this like:

tableland>update healthbot_1_1 set counter=4967;
(x) Confirm: Send this transaction to the network
( ) Oops. No, don't send that transaction.

you can decide to go ahead (confirm), or cancel the transaction.

The Tableland shell command is built to be simple; just write SQL, we’ll handle the rest.