<!-- https://qasignoff.com/docs/core-features/database/ -->
# Database workbench

* **Platform Availability:** Windows App · VS Code Extension
* **Overview:** Connect to a database, explore its schema, run SQL and check the results, next to your API requests. Connections and queries run from your machine, and passwords can be kept in an encrypted local vault.

![Database workbench start page with quick actions, pinned tables and saved runbooks](/docs/assets/screenshots/app/db-home.webp)

The screenshots on this page use a small SQLite demo database. The screens are the same on Windows and in VS Code.

## Supported databases

| Database | Notes |
|----------|-------|
| PostgreSQL | Default port 5432 |
| MySQL | Default port 3306 |
| SQL Server | Default port 1433 |
| Oracle | Default port 1521 |
| SQLite | Choose a local file |
| ClickHouse | Over HTTP, default port 8123: test, query and basic catalog browsing |
| Sample catalog | Built-in data for trying the workbench |

## Connect

1. Switch to **DB** and click **New Connection**.
2. Pick the **Database engine**. For a server database you can paste a connection URI and click **Parse URI** to fill in the fields.
3. Name the connection, choose a colour and tag it **DEV**, **STAGE**, **PROD** or **LOCAL**.
4. Fill in the host, port, database, username and password, or the file path for SQLite.
5. Click **Test Connection**, then **Save Connection**.

![New database connection form](/docs/assets/screenshots/app/db-connection.webp)

The test checks each stage in turn, so you can see which one failed. For SQLite, the stages are path, file, driver and open.

![Successful SQLite connection test with all four stages passed](/docs/assets/screenshots/app/db-connection-test.webp)

### Passwords and the vault

- **Save password securely in vault** encrypts the password on your machine. It is never written to workspace files.
- **Password env key** reads the password from the workspace `.env` instead.
- If you save to neither, the password is kept in memory until you close the app. After a restart, click **Enter Password**.
- The vault and the workspace list live in `%USERPROFILE%\.signoff-studio`. The Windows app and the VS Code extension share them, and updates and reinstalls do not touch them.
- If a vault exists and is locked, SignOff Studio asks for its passphrase when it opens. You can dismiss the prompt and unlock later.

### Access options

- **Read-only connection** blocks writes from the workbench.
- **Allow AI agent writes** is off by default, and never takes effect on production-like or read-only connections. Agents always read through a read-only transaction. See [MCP & CLI](/docs/core-features/mcp-and-cli/).

## Explore the schema

Expand a schema to see its tables. Expand a table to see its columns, types, primary key (🔑) and foreign keys (↗). Select a table to open it in the **Inspector**, which also has **Data**, **1-Hop**, **Copy** and **DDL** actions.

![Schema explorer with the orders table expanded and its inspector](/docs/assets/screenshots/app/db-explorer.webp)

- Filter the Explorer with `col:`, `type:`, `fk:`, `git:changed` or `locked:true`.
- Press **Space** on a table to peek at five rows.
- Pin the tables you use often. They also appear on the start page.
- Right-click a table for more actions, including a SELECT without blob columns, drift checks and copying names.

### Jump to anything

Press **Ctrl+P** to search tables, columns, connections, environments and `.sql` files. Use the arrow keys to move and **Enter** to open.

![Quick switcher showing tables and columns that match "order"](/docs/assets/screenshots/app/db-quick-switch.webp)

## Run SQL

1. Open a tab with **New Blank SQL Tab**.
2. Write your query and click **Run**.
3. Check the confirmation, then click **Execute Query**.

The confirmation shows the environment, the connection, the risk level and the exact SQL. Where it is offered, **Don't ask again** skips this check for that environment.

![Query confirmation showing a Local environment, a read-only risk level and the SQL](/docs/assets/screenshots/app/db-run-confirm.webp)

Results open below the editor. You can search, filter, copy, export or pin them, and use the **messages** and **plan** tabs for more detail.

![Query results: 12 rows from a join of orders and customers](/docs/assets/screenshots/app/db-query-results.webp)

- **Auto-Commit** shows whether each statement is committed straight away. Turn it off to use manual transactions where the database supports them.
- **Explain** shows the query plan, and **Format** tidies the SQL.
- **Stop** cancels a running query.

## Build a join

1. **Ctrl+click** (or **Cmd+click**) two to four tables, or use the fork icon on a table row.
2. SignOff Studio finds the shortest foreign-key path between them and adds any tables needed in between. Those are marked **VIA BFS**.
3. Choose **INNER**, **LEFT** or **FULL**.
4. Click **Insert JOIN into Editor** or **Copy SQL**.

![Join builder linking customers to products through orders and order_items](/docs/assets/screenshots/app/db-join-builder.webp)

Joins based on inferred foreign keys start as `LEFT JOIN`, because the database does not enforce those relationships.

## More tools

- **Import CSV / JSON** reads `.csv`, `.json` and `.ndjson` files, infers column types from the first 250 rows and imports in one transaction.
- **Export Schema Docs** copies Markdown with a Mermaid `erDiagram` and a column dictionary. Explicit foreign keys use `||--o{` and inferred ones use `||..o{`.
- **SQL runbooks** are saved `.sql` files with `:parameter` placeholders. Values are sent as driver parameters, not added to the SQL text.
- **Table workspace** shows structure and indexes, previews `ALTER TABLE` changes, profiles columns and compares the schema with its Git baseline.
- **Drift** compares a table's columns with another environment and can draft the `ALTER TABLE` SQL.
- **Database Driver Manager** shows driver versions and lets you update or roll back a driver.

## Use SQL in scripts

```javascript
const rows = await qa.db.query("SELECT 1 AS ok");
qa.expect(rows[0].ok).to.equal(1);
```

`qa.db` depends on what the host app allows. See [Tests & scripts](/docs/core-features/tests-scripts/).

## Troubleshooting

- **No password was provided:** the connection editor opens with the password field selected. Enter the password, and save it to the vault to keep it after a restart.
- **No saved password in the vault:** the vault is unlocked but has no password for this connection. Enter it again.
- **SQLite file not found:** use the full path, or click **Browse**. Save the connection only after the test passes.
- **A connection fails after an update:** check the driver in **Database Driver Manager**.
- **Narrow window:** below 900px, some toolbar buttons show only their icons. Use **Ctrl+B** or `◧` to hide the Explorer. VS Code may use **Ctrl+B** for its own sidebar, so use the button there.

## Next

- [Tests & scripts](/docs/core-features/tests-scripts/)
- [Workspaces](/docs/core-features/workspaces/)
- [MCP & CLI](/docs/core-features/mcp-and-cli/)
