Skip to content

CLI client karhutlasql-client ​

bash
export KARHUTLASQL_PASSWORD=...           # empty in a terminal = prompt
karhutlasql-client --host db.corp --tls-ca ca.crt          # REPL
karhutlasql-client --host db.corp --tls-ca ca.crt -c "SELECT 42"
karhutlasql-client --host db.corp --tls-ca ca.crt --format csv < report.sql > out.csv
FlagDefaultDescription
--host, --portlocalhost, 31337
-U, --usernameadmin
--password-envKARHUTLASQL_PASSWORDenv var name; the password never goes through argv
--tlsoffTLS with the system CAs; enabled automatically when any other --tls-* is set
--tls-caPEM CA to verify the server
--tls-skip-verifyoffdev only (server --tls-self-signed)
--tls-cert, --tls-keyclient cert for mTLS
-c, --commandexecute, then exit
--formattabletable, csv, json (one object per line)
--timingoffduration of each statement
--history-file~/.karhutlasql_history0600; "" = off
--oidc-issuerSSO: use the stored token (replaces the password)
--oidc-loginoffnew SSO login (Device Code), then store the token
--browseroffwith --oidc-login: Auth Code + PKCE via the browser
--oidc-client-idkarhutlasqlpublic client at the IdP
--token-file~/.karhutlasql/token.jsonSSO token (0600), refreshed automatically

Statements end with ; (a final statement without ; is still executed). -c/stdin mode stops at the first error with exit code 1; the REPL continues. Ctrl+C in the REPL cancels the running statement (the server cancels it too).

Meta commands (REPL and stdin): \dt list tables, \timing toggle, \? help, \q quit.

The table format holds the whole result in memory; use csv/json for large results.

SSO ​

bash
karhutlasql-client --host db.corp --tls-ca ca.crt \
  --oidc-issuer https://sso.corp/realms/data --oidc-login     # prints URL + code, waits for login
karhutlasql-client --host db.corp --tls-ca ca.crt \
  --oidc-issuer https://sso.corp/realms/data -c "SELECT 1"    # uses the stored token

Device Code suits SSH/headless use; --browser opens a browser and receives the redirect on 127.0.0.1. The token is refreshed 60 seconds before it expires.

Go library: pkg/client (client.Dial, Query, Tables; Config.TokenSource for SSO) and pkg/client/oauth (DeviceLogin, BrowserLogin, FileStore, TokenSource).

Other Flight SQL capabilities ​

  • Bulk ingest (CommandStatementIngest): e.g. Python cursor.adbc_ingest("table", arrow_table, mode="create"|"append"|"replace"|"create_append") or Go flightsql.Client.ExecuteIngest. The Arrow stream is written into one table in one transaction (failure = no rows land); requires write permission on the target table (SELECT-only roles and the MCP channel are rejected); queuing, quotas, audit, and access history apply as for write statements. Temporary tables and Flight SQL transactions are not supported.
  • PollFlightInfo (ADBC incremental execution): always completes on the first poll (progress = 1); the query is executed and streamed at DoGet.
  • GetSqlInfo: server & Arrow name/version, DuckDB dialect (identifier case, NULL ordering, subqueries, unions, keywords from duckdb_keywords(), scalar functions), bulk ingest supported, transactions not supported, statement timeout.

Released under the Apache 2.0 License.