# Connect an external database

Connect your own PostgreSQL or Supabase database and manage its tables with the same grid you use for datasets.

Source: https://support.rework.com/article/connect-an-external-database

Some data has to live in your own database: it feeds another system, it's too large to move, or company policy says so. **Databases** lets Rework work with tables stored in a PostgreSQL or Supabase database you control. The tables look and behave like datasets, with the same grid, record view and filters, while every row stays stored in your database.

Two things are involved:

| Object | What it holds | Who creates it |
| --- | --- | --- |
| **Connection** | The credentials: host, port, database, user, password | App admins |
| **Database** | A named workspace on top of a connection, with its tables, views and sharing | Anyone allowed, picking an existing connection |

> **Note:** Rework manages the tables **it creates** in your database. It doesn't browse or edit tables that already existed there, so connecting a production database never exposes its existing data.

## Step 1: Start a new database

- Click **Databases** in the left sidebar.
  
- Click **New connection**.
  

![The Databases page with the New connection button](https://storage.googleapis.com/reworkv3-public/success/260923/6kdg6YedX3XaMB7bW6AfTkoR03IdaBVaQdKL2ma38UiSwzHTMwZXyrnl1v66DP1u/img.AcHVN7SzS0mBsPH6zIRVx7gZ65hQUTAvXOjKJOXgQrlCTSc583cEzT42rwm7pHKe.png)

The **New database** dialog opens:

- **Name**: how your team will recognize it, for example _Northwind ops_.
  
- **Connection**: the connection it runs on. Pick an existing one, or click **New connection** to create one (App Admin only, see Step 2).
  
- **Template**: optional. Click **Browse templates** to create tables and an app from a template at the same time. See [Start from a template](https://support.rework.com/article/dataset-start-from-a-template).
  

![The New database dialog with Name, New connection and Browse templates](https://storage.googleapis.com/reworkv3-public/success/260923/Yd0nNBjgSWsaPpwK1Ndu7pcBFyHL0Cv8XQWisdiz5EsPCZ6bxczLuy5FUvvv6TE9/img.287Yff1SpG7MhHQUtTghDrxBG2mCsvyTK6NJ2N4jt8F33FUNOd7gw4WluSKihmJZ.png)

## Step 2: Create the connection

Click **New connection** inside the dialog and fill in the connection form:

- **Name**: a name for the credentials, for example _Northwind ops Postgres_.
  
- **Provider**: **PostgreSQL** or **Supabase**. **MySQL** is coming soon.
  
- **Connection string**: paste a `postgres://` URL to fill in the fields below in one go, or type them:
  
  - **Host**, **Port**, **Database**, **User** and **Password**.
    
- **Use SSL**: keep it on for any database reached over the internet.
  
- **Read-only data**: turn it on if Rework should only read, never write.
  

Click **Test connection** until it reports **Connection successful**, then click **Create connection**.

![The connection form with provider, credentials and Test connection](https://storage.googleapis.com/reworkv3-public/success/260923/i3LmLZWEvv0sC1gJdM06xgWdnCj96hvH0FkZIMDuI5wRSVgaKm4BfRdVKzYpTxcr/img.6ANFimY1FKkmWjzlU1nT5V4qUFEZbjv7IK21WXQz8C4ZoJ42nVrG6u79zr8452OQ.png)

### Where do I find these values in Supabase?

In your Supabase project, click **Connect**, then **Session pooler**. Use the host `aws-0-<region>.pooler.supabase.com`, port `5432` (session) or `6543` (transaction), user `postgres.<project-ref>`, database `postgres`, and your database password.

## Step 3: Create the database

Back in **New database**, your new connection is already selected. Click **Create database**.

![The New database dialog with the connection selected](https://storage.googleapis.com/reworkv3-public/success/260923/XzNIJ5YxsE9FgAjfwhkBZJq3JJg360qhxFJs6h31DOsUUXfORX3mg8CnM0tP8rAA/img.qUfisBGIg9toKGByWh5OaKCGhu8iCCWJlKzZV3dpJv1R1BDP83ulI1tT03DeQPR3.png)

The database opens on its **Overview**. It's empty at first, and that's expected:

- **New table** creates a table in your database.
  
- **Sync schema** refreshes what Rework knows about the tables it manages, which is useful after a change made directly in the database.
  

![The empty database overview with New table and Sync schema](https://storage.googleapis.com/reworkv3-public/success/260923/48XYRQ743PG8Y1RRl8sGMCqQbZUtsvzfq4y1Dc9CVsGmwF0H5yM043qW1HgRVMl1/img.oU9XKqRFNkNDcjDkgmEMcdnCTa4nhXYoQBQcKfVVFldMZSIzOzY3rcEnFW0vXqnF.png)

## Step 4: Create a table

In **Create table**, enter the **Table name**. The dialog shows the physical name it will use in your database, for example `equipment_loans`. Pick an icon and colour, then set up the columns:

- A **name** column is always added.
  
- Give every other row a column name and a type, or remove the row. **Create table** stays disabled while a column row has no name.
  
- Click **Add column** for more.
  

Click **Create table**. Rework creates the real table in your database.

![The Create table dialog](https://storage.googleapis.com/reworkv3-public/success/260923/vGn0e57apEhMZ7Y9WjmBNFonEYapAfrHGqrixUWWEorlMV6IV51DohPNRWysTst2/img.CdF65cHfAzbx1SEiZcuDicHpTquAWMDTczq550aztJb0dt8l7c7oIaLfKkVLBaQH.png)

## Step 5: Work with the table

Open the table from the database's left rail. **Add record**, **Filter**, **Sort**, **Group** and the record view work just as they do in a dataset. See [Add and edit records](https://support.rework.com/article/add-and-edit-records).

External tables offer two extra views on top of **Grid view** and **Kanban**:

- **Calendar**: records placed on a month or week by a date field, with an **Unscheduled** panel for records without a date.
  
- **Gantt**: records drawn as bars between a start and an end date, by **Week**, **Month**, **Quarter** or **Year**.
  

> **Note:** Connections for the whole workspace are listed under **Settings** > **Connections**, where admins can test, edit or remove them. See [Workspace settings](https://support.rework.com/article/workspace-settings).
