Skip to content

CLI

npm install -g @persql/cli
persql --help

Node 20 or newer. npx @persql/cli ... runs it without installing.

persql login opens the browser to the console (BROWSER=none prints the link instead), which shows the same code the terminal does; approve it and the terminal is signed in for a month of use, longer while it keeps being used. On a machine with no browser, persql login --key persql_... saves a developer key from the console’s Account page instead. The sign-in lives in ~/.config/persql/config.json (or under $XDG_CONFIG_HOME); PERSQL_KEY and PERSQL_API_URL in the environment override it, which is what a CI job wants.

Every command takes --json to print JSON instead of a table, and --help for its arguments. A <db> is a database’s id or its name.

CommandUsageDoes
loginpersql login [--key persql_...] [--api https://api.persql.com]Sign this terminal in through the browser, or save a developer key.
logoutpersql logoutForget the saved sign-in on this machine.
whoamipersql whoamiWho this terminal is signed in as.
dbspersql dbsList your databases.
createpersql create <name>Make a new, empty database.
renamepersql rename <db> <name>Rename a database.
droppersql drop <db> --yesDelete a database and everything in it.
tablespersql tables <db>The tables of a database with their row counts.
schemapersql schema <db>The schema of a database as SQL, or as JSON with --json.
querypersql query <db> <sql> [--param v]... [--csv] [--json]Run one SQL statement; a SELECT prints rows. Pass - to read the SQL from stdin.
importpersql import <db> <file>...Import files into a database: CSV, TSV, Excel, a SQL dump, a SQLite file, or a zip.
exportpersql export <db> [--as sql|sqlite|csv] [--table t] [--out path]Export a database as SQL or SQLite, or one table as CSV, to a file.
backupspersql backups <db>The backups of a database.
backuppersql backup <db> [--label text]Take a backup of a database, as a SQL dump you can download and restore.
restorepersql restore <db> <backup-id> --yesRestore a backup; a backup of now is taken first.
notespersql notes <db>The notes on a database: what a table is for, what a column means.
notepersql note <db> <about> <text>Add a note about a table or a column (table, or table.column).
mcppersql mcp [--config]Serve your databases to an agent over MCP on stdin/stdout; --config prints the client snippet.
persql create Ledger
persql import ledger expenses.csv                # any size; progress on stderr
persql query ledger "SELECT category, SUM(amount) FROM expenses GROUP BY 1"
persql query ledger "SELECT * FROM expenses WHERE day > ?" -p 2026-01-01 --csv > this-year.csv
echo "SELECT COUNT(*) FROM expenses" | persql query ledger -
persql backup ledger --label "before the clean-up"
persql export ledger --as sqlite -o ledger.sqlite
persql export ledger --table expenses -o expenses.csv
persql restore ledger snap_... --yes

Exit codes: 0 done, 1 the API refused or could not be reached, 2 the command was not understood.