> ## Documentation Index
> Fetch the complete documentation index at: https://endclose.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Postgres integration

> Connect Postgres to End Close through Fivetran and sync rows from a Postgres table into a data stream you can reconcile.

The Postgres integration syncs rows from a Postgres table into an End Close [data stream](https://endclose.com/docs/concepts/data-streams.md), with each row becoming one record. End Close connects through Fivetran: you enter your Postgres connection details in Fivetran's setup form, then choose the table and map its columns to record fields in End Close.

## At a glance

| | |
| - | - |
| **Connects as** | A Fivetran connection to your Postgres database |
| **Data synced** | Rows from one table per stream, as records |
| **Who can set it up** | Admins |
| **Per environment** | Yes. Each End Close environment has its own Postgres connection. |

## Prerequisites

* An End Close admin.
* Postgres connection details for a user that can read the tables you want to sync.
* A table with a column that uniquely identifies each row, such as a transaction ID, and columns for the amount, the date and the direction (credit or debit).

## Connect Postgres

**1. Open Postgres in End Close**

Go to **Settings → Integrations** and choose **Postgres** under **Data warehouses**.

**2. Enter the connection details in Fivetran**

Choose **Connect**. End Close sends you to a Fivetran setup form. Enter your Postgres connection details there and finish the form. The credentials go to Fivetran; End Close doesn't store them.

**3. Return to End Close**

Fivetran sends you back to End Close, and the Postgres dialog shows **Connected**.

If you leave the Fivetran form before finishing, the dialog shows **Action needed**. Choose **Finish setup** to return to the form.

## Create a Postgres stream

Each stream reads one table. Create one stream per table you reconcile.

**1. Start a new stream**

In the Postgres dialog, choose **New Postgres stream**. You can also start from **Data**.

**2. Choose data**

Under **Builder**, pick the table from **Table**. Then set the **Sync Key**: the column that uniquely identifies each row. End Close stores it as the record's `external_id`.

**3. Map columns**

Map a column to each required record field: **Amount**, **Date** and **Direction**. You can also map a column to **Description**. Choose **Continue** when the required fields are mapped.

**4. Name and save**

Enter a **Key** (for example `production_postgres`), a **Name** and, optionally, a **Description**, then choose **Create stream**. The key is used in URLs and the API, and can't be changed later.

End Close then sets up the Fivetran sync for the table, and rows arrive in the stream as Fivetran delivers them.

## FAQ

> [accordion] Can I sync the result of a SQL query instead of a table?
>
> Not yet. The **SQL** option in **Choose data** isn't available, so each stream reads a table. To sync a filtered or joined result, create a view in Postgres and pick that.

> [accordion] Can I sync several tables?
>
> Yes. Create one stream per table. They all use the same Postgres connection.

## Related

> [card] [Data streams](https://endclose.com/docs/concepts/data-streams.md)
>
> How streams hold records and feed reconciliations.

> [card] [Records](https://endclose.com/docs/concepts/records.md)
>
> The record fields your columns map to.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.