Terminal

SQL CLI tool and terminal database client

An SQL CLI tool is a program that sends SQL (Structured Query Language) to a database from a command line. A terminal database client is that program running in a terminal, the text window where you type commands. A command line database client is the same kind of program: you type a command instead of clicking in a desktop window. Query database from terminal means you type that command and read the rows it prints. CLI (command-line interface) is the short name for this way of working. DataTug's CLI is the datatug program.

Terminal appAvailable

Chat in the terminalAvailable

The install commands and flags below are copied from the install documentation, the installer script on this site, and the CLI reference. This page does not add a path or a flag those sources do not list.

One binary, two ways to work

A text user interface (TUI) is a full-screen program drawn with text. A bare datatug starts that terminal UI (user interface). The flag --tui is accepted and ignored. The TUI is a project picker, a schema tree, a query editor, a results pane, and history. It needs a TTY (teletypewriter), which means an interactive terminal session. The CLI page names these terminals: iTerm2, Alacritty, kitty, Terminal.app, and Windows Terminal.

The other mode is one-shot commands. They read flags and, where a command says so, standard input. They write results to standard output and diagnostics to standard error. query run chooses the format with --format: grid by default, or JSON (JavaScript Object Notation), JSONL (JSON Lines, one JSON value per line), CSV (comma-separated values), or YAML (YAML Ain't Markup Language), a text format. compare has --json. These commands are meant for shell pipelines, continuous integration (CI) jobs, Makefiles, and artificial intelligence (AI) agents.

Terminal chat is a separate available path. The product names its start as datatug chat. This page does not add flags for that command. The CLI page is the longer description of the two modes.

Install the SQL CLI tool

None of these methods needs Go. On macOS and Linux the install documentation runs the script from a temporary file:

(p=$(mktemp) && trap 'rm -f "$p"' EXIT && curl -fsSL https://datatug.app/get-cli -o "$p" && sh "$p")

The script file itself also shows this one line, and that is the command the platform home prints:

curl -fsSL https://datatug.app/get-cli | sh

The script checks the operating system and architecture, downloads the matching release from GitHub releases, verifies the SHA-256 (Secure Hash Algorithm, 256-bit) checksum, and installs datatug into ~/.local/bin unless DATATUG_INSTALL_DIR is set to another absolute path. DATATUG_VERSION can pin a tag such as v0.32.0. When that directory is not on PATH, the list of directories the operating system searches for programs, the installer appends one line to the shell startup file. DATATUG_MODIFY_PATH=0 skips that edit and prints the line to add yourself.

Windows PowerShell, for current amd64 releases, installs to %LOCALAPPDATA%\DataTug\bin. In that command, irm is Invoke-RestMethod and -EA is ErrorAction:

$p=Join-Path $env:TEMP ("datatug-"+[guid]::NewGuid()+".ps1"); try { irm https://datatug.app/get-cli.ps1 -OutFile $p -EA Stop; & $p } finally { Remove-Item $p -EA SilentlyContinue }

Homebrew on macOS or Linux:

brew install --cask datatug/tap/datatug

Then check the binary:

datatug --version

The script addresses are datatug.app/get-cli and datatug.app/get-cli.ps1. DataTug CLI is open source under the Apache License 2.0.

Query a database from the terminal

TugQL is DataTug's query language for sources, joins, filters, and columns. It is not a SQL dialect. datatug query run is the command that reads rows. A whole collection uses --from. A TugQL document uses -f or --file. Raw SQL text in that file fails with invalid TugQL. A saved library query uses --project and --query instead of --db.

This recorded command reads every row and field of Shippers from a local SQLite file and prints JSON. --no-policies runs without a DataTug access policy:

datatug query run --db "sqlite://$PWD/northwind.sqlite" --from Shippers --no-policies --format json

--db takes sqlite://, ingitdb://, http://, or https://, or env:NAME when that name holds a PostgreSQL, MySQL, Oracle, or SQL Server address in an environment variable. An HTTP (Hypertext Transfer Protocol) or HTTPS (HTTP Secure) address points at a local project directory of saved HTTP queries, not at an arbitrary remote URL (uniform resource locator). One --db address is one source. It does not join PostgreSQL and MySQL by itself.

A saved query can be SQL, TugQL, or HTTP, according to the query file. The CLI reference runs one like this:

datatug query run --project demo-project-1 --query customers/customer-invoices \
  --env local --as boss --role admin --var CustomerId=5

A saved query whose type is SQL is opaque text. It needs its own opaqueQuery: true grant. The reference names customers/customer-purchases-by-genre as a verified SQL-type run of that kind. Row filters and column allow-lists are not applied to native SQL. See Native SQL access policies.

The supported databases catalogue lists SQLite, PostgreSQL, MySQL, Oracle, and SQL Server as command-line sources for read-only SQL and TugQL, with schema scan implemented. A server read on PostgreSQL, MySQL, Oracle, and SQL Server requires unrestricted access, which the CLI calls --no-policies. Do not assume row or column policy enforcement on those engines. --no-policies skips DataTug's access policy. It does not take write permission away from the database login. Use a login that can only read. The catalogue's browser and hosted column says "Not verified by this catalogue" on each row.

Not every catalogue row accepts SQL text. Query Firestore with SQL is a CLI path that rejects SQL. The catalogue is the operation-by-operation list, including sources whose query path is TugQL only.

Commands the binary already has

These are commands the CLI reference and the CLI page document as present. datatug -h and datatug <command> -h are the current list. This table does not include commands the reference marks as not in the release.

CommandWhat it does
datatugStarts the terminal UI
datatug query runReads a collection, a TugQL file, or a saved query
datatug scanWrites schema metadata into a project directory
datatug showPrints schemas, tables, and columns from a scan
datatug compareCompares two databases a project declares, schema first, then rows
datatug db copyCopies tables between databases
datatug db exportWrites a database as plain files for Git
datatug serveServes a local HTTP API (application programming interface). The default port is 8989
datatug mcpSpeaks to a desktop agent over standard input and output, in front of a datatug serve you already started
datatug --versionPrints the version

Worked output for compare, copy, and export is on the compare page and the copy and export page. MCP for database is the setup for datatug mcp, DataTug's database MCP server. MCP (Model Context Protocol) is the open standard that server speaks. It is not a SQL prompt.

Query multiple databases at once is a TugQL join in this CLI, when both sources are in one project. Join PostgreSQL and MySQL is the how-to. That page does not publish a PostgreSQL-to-MySQL row count. The recorded cross-source run it cites is a different pair of sources.

The same project, other doors

The pricing page says the CLI and terminal app are free to use, for personal and for business use, within the Free plan's limits. The browser workspace is a separate surface. Ways to use DataTug is the map of the browser, the terminal, and an agent against one project.

All features · What is an MCP server · Supported databases · Compare