Skip to content
Ursa Shell

Command line

ursa with SQL to run runs it and exits, as duckdb -c does. In a terminal with nothing to run it starts the shell.

The shell starts only when there is no SQL to run and the input is a terminal. These run SQL and exit:

ursa club.ursa -c "SELECT * FROM degree(karate)" # one or more statements
ursa club.ursa -f query.sql # a file of SQL (or --file)
echo "SHOW GRAPHS;" | ursa club.ursa # SQL on stdin

-c and -f (--file) may be repeated; they run in the order given. If any statement fails, ursa prints the error, stops, and exits with status 1. A syntax error anywhere in a -c, a file or stdin runs none of it.

Ctrl-C (SIGINT) cancels the run: ursa stops the query that is running, prints Error: interrupted to stderr, writes nothing more to stdout, and exits with status 130. Results that finished before it stay printed. The database is left as the last finished statement left it, and another process can open it at once. In the shell, Ctrl-C cancels the running statement, prints Interrupted to stderr and draws the prompt again at once.

A script may hold dot-commands too, one a line, as at the prompt and as in DuckDB:

.timer on
.mode csv
SELECT count(*) AS edges FROM 'karate_edges.csv';
ursa -f q.sql
edges
78
Run Time (s): real 0.004 user 0.006113 sys 0.001024

The timer reports, as DuckDB’s does, the wall-clock time (real) and the CPU time the process spent in its own code (user) and in the operating system (sys). Those two add up the time of every thread, so a query that runs in parallel can use more CPU time than real time.

.read FILE in a script runs another script. In a script, .quit and .exit end the run there, with status 0. An unknown dot-command is an error, as a failing statement is. With --format arrow, the output is one Arrow stream: text a dot-command prints, such as the timer’s, goes to stderr instead.

Statements that return rows always print a result, with its header even when there are no rows. Statements that return no columns, which are DDL (CREATE, DROP) and SET, print nothing, as in DuckDB. In ndjson, which has no header, a result with no rows prints nothing. A statement that fails prints nothing to stdout, not even its header, so a script never reads a header with no rows for a query that failed; the error goes to stderr. (Rows are written as they arrive, so a query that fails after its first rows have been written has written them.)

Add --readonly to open a database without changing it. See the database file.

Notices, such as a slow graph index build or an index the database could not keep, go to stderr as lines starting ursa: , so stdout holds only results. --quiet (-q) turns them off. See notices.

ursa --skill prints a guide to writing Ursa SQL, in Markdown: an agent skill built into the binary, so it always matches the version you run. An agent can read it before writing queries, or you can save it where your agent loads skills, for example for Claude Code:

mkdir -p ~/.claude/skills/ursa-sql
ursa --skill > ~/.claude/skills/ursa-sql/SKILL.md

An agent should read results as --format json or --format ndjson (see Reading results in a program): a table shows at most 40 rows, while CSV and JSON write every row.

ursa serve runs the same shell in a browser tab on your machine, over a local WebSocket to this native engine, with the graph view beside it:

ursa serve # in memory, in the current directory
ursa serve data/ # relative paths in queries are data/'s
ursa serve club.ursa # the database, as `ursa club.ursa` opens it

It prints a link with a one-time token and opens it in your default browser; --no-open only prints it. To open it, it gives the browser a page that redirects to the link, written to a temporary directory only you can read and removed when the server stops, so the token is never on a command line, where other users of the machine could see it. A browser that cannot read the temporary directory (Firefox installed as a snap, on Ubuntu, has a /tmp of its own) shows an error: open the printed link instead. It listens on 127.0.0.1 and ::1 only, on port 4280 or the next free one (--port N). Ctrl+C stops it.

A directory, or a database file’s own directory, is where relative paths resolve, and where the server writes: COPY … TO, .output and .once take a relative path under it. The shell’s tab keeps what COPY … TO 'name' writes in the session, as Ursa Shell in the browser does (.files lists them).

--read-only writes no files, for pairing with an agent: COPY … TO, INSERT INTO a table of files, .output, .once, ATTACH of a database that does not exist, and anything that would change the database (opened read-only) are refused. Views and tables in memory still work.

The release binaries (the installers’ and GitHub’s) have the page built in. A build with cargo install ursa-cli --features serve has not: pass --assets DIR, a web/dist built from Ursa’s repository.