---
title: "Connecting to Postgres"
description: "You can establish a direct connection to Postgres to pull in data into xP&A.\n\nIt is possible to use an SSH tunnel for the connection."
source_url: https://support.lucanet.cloud/en/documentation/xp-a---extended-planning-and-analysis/integrating-data/connecting-to-a-data-source/connecting-to-a-bi-data-warehouse-system/connecting-to-Postgres
language: en
last_updated: 2023-08-16
---
# Connecting to Postgres

## Overview

You can establish a direct connection to Postgres to pull in data into xP&A.

It is possible to use an SSH tunnel for the connection.

This article contains a description of the prerequisites and the individual steps of the set-up process.

{% info-box %}
The fields that are pulled in must be defined during the set-up process using a database query. For a detailed instruction on how to structure such a query, see [Defining Database Queries](https://support.lucanet.cloud/en/documentation/xp-a---extended-planning-and-analysis/integrating-data/connecting-to-a-data-source/connecting-to-a-bi-data-warehouse-system/defining-database-queries.md).
{% /info-box %}

## Prerequisites for the Setup

### Whitelist IP Address in Postgres

Before connecting Postgres with xP&A, you have to whitelist the following IP address in your Postgres database:

- 52.59.129.235

### Optional: Preparation for Connection via SSH Tunnel

If you want to establish a connection via an SSH tunnel, a user called causal must be created on the remote SSH server and the following public key must be associated with it:

**ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP9DCR3hBNU/01YU9iK1JMKx2HNsK1+3ChWj3yBqb+Kr causal**

{% stepper %}
{% stepper-step %}
Choose one of the following options:

- Open the **Data** workspace from the overview on the start page and click **\+ New.**

New data source connection from the Data workspace

- Open the model into which you would like to integrate the data, click the **+** sign next to **Data** in the overview, and choose **New data source**:

New data source connection from within a model
{% /stepper-step %}
{% stepper-step %}
In the **Data sources** dialog, open the **BI/Database** tab and choose **Postgres**

'BI/Database' tab
{% /stepper-step %}
{% stepper-step %}
The **New Data Source** dialog is displayed as follows:

'New Data Source' dialog for Postgres
{% /stepper-step %}
{% stepper-step %}
Configure the steps as described in the following section.
{% /stepper-step %}
{% stepper-step %}
Click **Create data source**.
{% /stepper-step %}
{% /stepper %}

### Set-up Steps

#### Choose a connection

Choose an existing connection, or, if you have not configured a connection yet, click **New Connection** and enter the following in the **New Postgres connection** dialog:

- Postgres database host name without port and database
- Postgres database port
- Name of the database to which you want to connect
- Database user name
- Database user password

#### Complete the query form

##### Enter the following:

- Data Source Name
- Query to define the fields which are to be pulled in. For more information, see [Defining Database Queries](https://support.lucanet.cloud/en/documentation/xp-a---extended-planning-and-analysis/integrating-data/connecting-to-a-data-source/connecting-to-a-bi-data-warehouse-system/defining-database-queries.md).
- Name of the **Date** column, which must be one of Postgres's date formats
- Names of the columns that contain variables (which must have a **numeric** data type.)

{% idea-box %}
Any remaining columns will be treated as dimensions, and must have a **string** data type.

An exception is the **cohort** dimension, which must be a date, with the column header explicitly labelled **Cohort**.
{% /idea-box %}
