Skip to main content

Terminal and DDEV

TablePro opens any database URL passed to it by the operating system. That makes it scriptable from the shell, and it is how the DDEV integration below works.

Open a database from the shell

Pass a connection URL to open:
open "mysql://[email protected]:3306/shop"
open "postgresql://user:[email protected]:5432/app?table=orders"
TablePro uses a saved connection if one matches, otherwise it opens a temporary session that is never written to disk.

Force TablePro over another client

open "mysql://..." goes to whichever app owns the mysql:// scheme. If TablePlus or another client is installed, it may win. Target TablePro by its bundle identifier:
open -b com.TablePro "mysql://[email protected]:3306/shop"

Install the tablepro command

Open Settings > General > Command Line and click Install. This writes a small tablepro script to /usr/local/bin that always opens TablePro:
tablepro "mysql://[email protected]:3306/shop"
tablepro
/usr/local/bin is owned by root on a stock macOS install, and may not exist at all. When TablePro cannot write there itself, macOS asks for your administrator password, and TablePro then creates the folder and the command. Cancel the password prompt and nothing is written. If that fails too, Settings falls back to showing the exact sudo command to run in Terminal. Run it and switch back to TablePro, and Settings picks up the change on its own.

DDEV

DDEV ships a tablepro command. From any project:
cd my-project
ddev tablepro
DDEV adds the command automatically when TablePro is installed in /Applications. If ddev tablepro is not found, update DDEV. This is the right way to open a DDEV database, because DDEV gives the project a new host port on every ddev start. A saved connection goes stale; the command reads the current port each time. It works with both MySQL/MariaDB and PostgreSQL projects. DDEV’s database, user, and password are all db. The first time a link connects, TablePro asks you to confirm it. This stops a web page from silently opening a connection. For a database on your own machine (localhost, 127.0.0.1, or ::1), the alert also offers Always Allow. Choose it and TablePro stops asking for that database, so ddev tablepro connects straight away. Trust is keyed on the database type, host, database name, user, and the name parameter, but not the port, because DDEV changes the port on every start.
Only databases on your own machine can be trusted. A link to a remote host always asks, every time.
Review and remove trusted links in Settings > General > Trusted Links. A link that carries SQL (?query=), a filter (?condition=), or a pre-connect script still asks for confirmation, even when the connection is trusted.