The Database panel lists the tables in a database, pages through their rows, and runs SQL. It works with the SQLite databases in your app, and with PostgreSQL, MySQL, MariaDB and SQLite databases the desktop app connects to directly.
Setting up Database in the SDK
Using the Database panel
Section titled “Using the Database panel”Choosing a database
Section titled “Choosing a database”Pick a database from the list at the top of the panel. Your app’s databases come first, in the order you passed them, then the direct connections you’ve added.
Adding a connection
Section titled “Adding a connection”Click Add connection (+) beside the database list, choose an Engine, and fill in the connection details.
Name is optional and defaults to user@host/database. For SQLite file, click Browse… to
pick an existing file.
Click Test connection to check the details, then Save. To change or delete a connection, select it and click Connection settings beside the list.
Connections are saved on your computer. Passwords are stored in your system’s keychain, such as the macOS Keychain. To be asked for the password each time instead, check Don’t save password, ask on connect. See Keychain.
Check Read-only to block every write, from the grid and from SQL.
SSH tunnel
Section titled “SSH tunnel”Under SSH tunnel, turn on Connect through SSH and enter the SSH host, SSH port and SSH user. Choose Password or Private key for SSH authentication. The server’s host key is pinned on the first connection. If it changes, connecting fails until you click Forget beside Pinned host key.
Under TLS, choose a TLS mode: Disable, Prefer, Require, Verify CA or Verify full. Prefer is the default. Add a CA certificate file, Client certificate file or Client key file if the server needs them. Verify full isn’t available through an SSH tunnel.
Browsing tables
Section titled “Browsing tables”The tables are listed on the left. Views are marked view, and PostgreSQL tables are grouped by
schema. Type in Search tables to filter them by name. On PostgreSQL, include the schema to
search within it, as in auth.users.
Click Refresh to read the tables and the open table again.
Browsing rows
Section titled “Browsing rows”Select a table to see its rows. More load as you scroll. On large PostgreSQL, MySQL and MariaDB tables, the row count is an estimate, shown with ~.
- Order by sorts by a column, and the button beside it switches between ascending and descending. Each column header’s menu can also sort, or pin the column to the left.
- Columns hides and shows columns. Drag the edge of a header to resize a column.
Editing rows
Section titled “Editing rows”Double-click a cell to edit it. Press Enter to save, or Esc to cancel, and
click NULL to set it to NULL.
Click Add row to add a row. Fill in the cells, using Tab to move between them. A cell left empty gets the column’s default. Click Save new row to write it, or Discard new row.
To delete a row, click Delete row (the bin icon) at its start, then Delete.
Views and BLOB values can’t be edited.
Every table can be edited. Rows are identified by their rowid, or by their primary key in a
WITHOUT ROWID table.
PostgreSQL, MySQL and MariaDB tables need a primary key to edit or delete rows. Read-only connections can’t be edited.
Running SQL
Section titled “Running SQL”Click SQL to open the editor. Table and column names autocomplete. Click Run, or press
⌘+Enter (Ctrl+Enter on Windows and Linux).
Several statements run in order and stop at the first error. The result of the last query shows in the grid, up to 1000 rows. Click Clear to go back to the table.
Before running a DROP, or an UPDATE or DELETE without a WHERE, the panel asks you to
confirm.
On PostgreSQL, MySQL and MariaDB, click Cancel to stop a running query. A query that runs for more than 30 seconds is stopped. A query on a SQLite file can’t be cancelled.
Cancelling is best effort, and doesn’t roll anything back. It stops the statement that’s running and skips the rest. Statements that already finished stay applied, and so does a statement that finishes before the cancel reaches the database.
Saving snippets
Section titled “Saving snippets”Click Save as snippet to keep the SQL in the editor. SQL snippets lists them, to insert into the editor, run, edit or delete. Snippets are shared between databases of the same type.
Limits and Troubleshooting
Section titled “Limits and Troubleshooting”BEGIN,COMMITand other transaction statements are refused.- A query’s result shows at most 1000 rows.
- BLOB values show their size only and can’t be edited.
- “Your app has disconnected”: its databases leave the list, except the one you’re viewing, which stays until you leave the panel. Reconnect your app to bring them back.
- “The SSH server’s host key has changed”: if you trust the new key, click Forget beside Pinned host key in the connection’s settings, then connect again.