# PostgreSQL

You can connect Tability to PostgreSQL to automatically pull query results into your check-ins.

Once you add PostgreSQL as a data source for an outcome/Key Result, Tability can:

* Run your saved query and preview the current numeric value in the check-in flow.
* Automatically sync your metric while the plan is active on Premium subscriptions.

{% hint style="info" %}
Available on Plus and Premium subscriptions
{% endhint %}

## How to enable the integration

### Step 1. Open the integrations page

Go to **Workspace Settings > Integrations**.

### Step 2. Connect PostgreSQL

1. Find **PostgreSQL** in the **Data connectors** section
2. Click **Connect to PostgreSQL**
3. Enter the database name
4. Enter the server host
5. Enter the server port
6. Enter the username and password
7. Click **Save**

This creates a workspace-level PostgreSQL connection.

## How to add a data source to an outcome/key result

### Step 1. Open the outcome or KPI editor

Open your outcome or KPI, then go to the **Data Source** tab.

### Step 2. Select PostgreSQL

Choose **PostgreSQL** from the list of available data sources.

### Step 3. Write your SQL query

Add the SQL query Tability should run to fetch the metric.

The current UI only accepts:

* `SELECT` queries
* Queries without semicolons

### Step 4. Save and preview

Click **Save & preview** to validate the query and load the current value.

## How the data source is used in check-ins

Once the connector is saved, Tability runs the saved query and displays the current numeric result in the check-in form.

If auto-sync is enabled on a Premium subscription, Tability will also create synced check-ins automatically while the plan is active.
