> ## Documentation Index
> Fetch the complete documentation index at: https://ngquct-docs-fix-500-query-results.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Terminal and DDEV

> Opening databases and files from a shell script, and wiring up a ddev tablepro command

`open "mysql://…"` goes to whichever app claims the `mysql://` scheme, and with TablePlus or another
client installed that may not be TablePro. Name TablePro instead, either by bundle identifier or
through the `tablepro` command:

```bash theme={null}
open -b com.TablePro "mysql://root@127.0.0.1:3306/shop"
tablepro "postgresql://user:pass@127.0.0.1:5432/app?table=orders"
```

Any [connection URL](/connections/urls) works, including its query parameters. TablePro uses a saved
connection when one matches on type, host, port, database and user; otherwise the session is
temporary and never written to disk. Running `tablepro` with no argument opens the app and nothing else.

## Install the tablepro command

Open **Settings > General**, find **Command Line**, and click **Install**. It writes a small script at
`/usr/local/bin/tablepro` whose whole body is `exec open -b com.TablePro "$@"`.

<Frame caption="The Command Line section in Settings > General">
  <img className="block dark:hidden" src="https://mintcdn.com/ngquct-docs-fix-500-query-results/hA72m8tSnRe3b-ew/images/command-line-install.png?fit=max&auto=format&n=hA72m8tSnRe3b-ew&q=85&s=883042ba08c956c1d920829a37a0f90c" alt="Command Line install section in TablePro settings" width="1560" height="960" data-path="images/command-line-install.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/ngquct-docs-fix-500-query-results/hA72m8tSnRe3b-ew/images/command-line-install-dark.png?fit=max&auto=format&n=hA72m8tSnRe3b-ew&q=85&s=27ac9680728b5797cf95a34943a4b29d" alt="Command Line install section in TablePro settings" width="1560" height="960" data-path="images/command-line-install-dark.png" />
</Frame>

That directory is root-owned on a stock macOS install, so expect an administrator password prompt.
Cancel it and nothing is written. If the write fails anyway, Settings prints the exact `sudo` command
to paste into Terminal; run it, switch back, and the status updates itself.

**Uninstall** removes the script again. When something else already occupies that path, **Install**
is dimmed and Settings says *"A different file already exists at …"*: remove that file first.

## Open a file

Files route the same way, whether double-clicked in Finder or passed on the command line:

```bash theme={null}
tablepro schema.sql
tablepro app.db
```

* `.sql`, `.psql` and `.pgsql` open in a query tab on the current connection. A window already
  holding that file comes to front. With no connection open, the file waits until you connect.
* Database files open a connection to the file itself and save nothing: `.db`, `.db3`, `.s3db`,
  `.sl3`, `.sqlite`, `.sqlite3` and `.sqlitedb` open with SQLite, `.duckdb` and `.ddb` with the
  DuckDB plugin. A window already connected to that file comes to front instead of a second one
  opening.

## DDEV

[DDEV](https://ddev.com) ships a `tablepro` command of its own. From any project:

```bash theme={null}
cd my-project
ddev tablepro
```

If `ddev tablepro` is not found, update DDEV. It covers MySQL, MariaDB and PostgreSQL projects, and
DDEV's database, user and password are all `db`. Prefer it over a saved connection: `ddev start`
hands the project a new host port each time, and the command reads the current one.

## Trusting a link

The first time a link connects, TablePro asks: **Open External Database Connection?**, showing the
host, user and database. This is what stops a web page from opening a connection behind your back.

For a database on your own machine (`localhost`, `127.0.0.1`, `::1`, or any `127.x.x.x` address) the
alert adds **Always Allow**. Choose it and that database stops asking, which is what makes
`ddev tablepro` a one-step command. Trust is keyed on database type, host, database name, user and
the URL's `name` parameter, deliberately not the port, since DDEV changes the port on every start.

<Frame caption="The confirmation alert for an external database link">
  <img className="block dark:hidden" src="https://mintcdn.com/ngquct-docs-fix-500-query-results/HJY892UtvXUv1PFn/images/link-trust-alert.png?fit=max&auto=format&n=HJY892UtvXUv1PFn&q=85&s=7ba256cc2f216f53944df7502bf2494a" alt="Alert asking to confirm an external database link, with Always Allow for local databases" width="1560" height="960" data-path="images/link-trust-alert.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/ngquct-docs-fix-500-query-results/HJY892UtvXUv1PFn/images/link-trust-alert-dark.png?fit=max&auto=format&n=HJY892UtvXUv1PFn&q=85&s=e5230baaad0c505fd25d66629bb0525e" alt="Alert asking to confirm an external database link, with Always Allow for local databases" width="1560" height="960" data-path="images/link-trust-alert-dark.png" />
</Frame>

<Note>
  A link to a remote host asks every time. Only a database on this machine can be trusted.
</Note>

**Settings > General > Trusted Links** lists what you have trusted, with **Forget** per entry and
**Forget All**. Two things still prompt even on a trusted connection: a link carrying a filter
(`?query=`, `?condition=` or `?raw=`) confirms the filter, and a connection with a pre-connect script
shows the script.
