# Differences from psql

`-c`, `-f`, `-t`, `-A` and `-x` mean what they mean in psql, so this prints a
bare number in either program:

```bash
hsql -tAc "select count(*) from orders"
```

It prints it the same way against every [adapter](https://harlequin.sh/docs/adapters), which is the
part psql cannot do.

## What Is Different

|                             | psql                                                | hsql                                                                                    |
| --------------------------- | --------------------------------------------------- | --------------------------------------------------------------------------------------- |
| `-P`                        | `--pset`, an output setting                         | `--profile`, a [config-file profile](https://harlequin.sh/docs/config-file)                                 |
| Field separator             | `-F`                                                | `--csv`, `--format tsv`, or any other [`--format`](https://harlequin.sh/docs/hsql/formats)                  |
| Listing databases           | `-l`                                                | [`--catalog`](https://harlequin.sh/docs/hsql/catalog)                                                       |
| Describing an object        | `\d`, `\dt`                                         | `--catalog --path`, `--catalog-search`                                                  |
| Stopping on the first error | `-v ON_ERROR_STOP=1`                                | `--on-error stop`, the default                                                          |
| One transaction             | `-1`                                                | write `begin` and `commit` in your script                                               |
| `-o`                        | a file for query output                             | a file, or a directory that gets one file per result set                                |
| Connection flags            | `-h`, `-p`, `-U`, built in                          | the adapter's, so `hsql --help -a postgres` lists them                                  |
| Row limits                  | none                                                | [500 rows by default](https://harlequin.sh/docs/hsql/safety); `--limit -1` removes it                       |
| Suppressing chatter         | `-q`                                                | nothing to suppress: stdout is only ever results                                        |
| Exit codes                  | `1` its own error, `2` connection, `3` script error | [`1` query error, `2` usage/config, `3` connection, `4` timeout](https://harlequin.sh/docs/hsql/exit-codes) |

> **Warning:** `-t` is _tuples only_, as in psql, not Harlequin's theme flag. Connection
> strings are positional, so `hsql -t nord -c "..."` parses, `nord` becomes a
> connection string, and hsql says so on stderr.

## No Backslash Commands

hsql has no meta-commands. What they do, options do:

- `\d`, `\dt`, `\l` — [`--catalog` and `--catalog-search`](https://harlequin.sh/docs/hsql/catalog),
  which produce ordinary result sets.
- `\copy` — [`--csv` and `-o`](https://harlequin.sh/docs/hsql/formats), or `--format parquet`.
- `\timing` — `--stats`, which reports `elapsed_ms` on stderr.
- `\c` — a different profile: `-P NAME`.
- `\set` — the profile, or the command line. One invocation, no session
  variables.

## No Interactive Session

hsql executes what it was passed and exits; there is no prompt. For an
interactive session, [Harlequin](https://harlequin.sh/docs/getting-started/usage) uses the same
adapters, config files and profiles: `harlequin -P prod`.
