# Connect to PostgreSQL

> Reverse engineer PostgreSQL to an ERD with Schemity. Every connection field explained - host, port, database, username, password, schema, and encryption - all offline.

Source: https://schemity.com/doc/connect-postgresql/

Connecting to PostgreSQL lets you **reverse engineer PostgreSQL to an ERD** in seconds. Schemity reads your tables, columns, primary and foreign keys, unique constraints, indexes, and check constraints, then draws the whole schema.

## How do I connect Schemity to PostgreSQL?

Click **+** above the diagram list, set **DB type** to **PostgreSQL**, click **Connect to a database**, and set **Connect via** to **Direct connection** (or **SSH Tunnel** to reach a database behind a bastion).

## What do the PostgreSQL connection fields mean?

- **Host** and **Port** - the server address and port. Port defaults to `5432`.
- **Username** - the role Schemity authenticates as. A read-only role is recommended for documentation.
- **Password** - the role's password. It is stored in your OS keychain, never in the JSON file. Leave it blank when editing to keep the existing one.
- **DB name** - the database to introspect.
- **Schema** - the schema to read. Defaults to `public`.
- **Encryption** - **Disable** (local dev only), **Require**, **Verify CA**, or **Verify full (recommended)**; the two verify modes also check the server certificate. See [encryption and certificates](https://schemity.com/doc/connections-overview/#how-do-i-encrypt-the-connection-and-verify-the-server-certificate). Use Verify full for any managed or cloud-hosted Postgres.

If you chose **SSH Tunnel**, an extra block asks for the SSH host, port (default `22`), username, password, and an optional SSH key file.

## What does Schemity import from a PostgreSQL schema?

Once connected, Schemity imports every table in the target schema - there is no table-picking step. It reads tables and columns with their PostgreSQL types, primary keys and nullability, foreign keys (with their ON DELETE / ON UPDATE actions) drawn as crow's foot relationships, unique constraints, indexes, and check constraints.

## Does Schemity work with Supabase and managed Postgres?

Schemity works as a **Supabase schema diagram** tool and with any managed Postgres: use the host, port, and **Require** encryption your provider gives you. Everything renders locally, so you get a private picture of a cloud database without uploading anything.

## Next

Save the diagram to Git (see [Version Control in Git](https://schemity.com/doc/version-control-git/)), or tidy the layout on [The ERD Canvas](https://schemity.com/doc/erd-canvas/).
