# Native client

The supplied native client opens an authenticated, stateful CoordinatorDB connection. Start the server, then run `./coordinator client --database data` for an interactive session.

## Connection options

`--addr HOST:PORT` overrides the default `127.0.0.1:7400`. `--user` defaults to `default`. The password comes from `--password` when supplied, otherwise `COORDINATOR_PASSWORD`, otherwise an empty string.

## Interactive SQL

Enter complete SQL and press Enter. A final semicolon is optional. Incomplete quotes and trigger bodies continue on another line; a trailing backslash also continues an otherwise complete line.

Separate statements with semicolons. Type `help` for commands and `.quit` to leave. Up/Down recalls history, and Tab completes keywords, databases, tables and columns. Piped SQL does not read or write interactive history.

## Scripted requests

```sh
./coordinator client --database data --query "SELECT 1 AS value FORMAT csv"
```

```text
1
```

`--query` runs one request and writes only result bytes to stdout, including binary output. Redirected stdin can supply attached `INSERT ... FORMAT` input. FROM INFILE reads files on the client machine.

## Session state

The connection retains database selection, temporary tables and open transactions. Closing it rolls back uncommitted changes.

See [native TCP](https://coordinatordb.com/docs/concepts/features/interfaces/tcp), [batch inserts](https://coordinatordb.com/docs/concepts/features/operations/insert/bulkinserts) and [transactions](https://coordinatordb.com/docs/concepts/features/operations/insert/transactions).
