> ## Documentation Index
> Fetch the complete documentation index at: https://domoinc-openapi-sync-dataflows.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# PostgreSQL SSH Connector

## Intro

PostgreSQL is a widely used open-source relational database management system. You can use Domo's PostgreSQL SSH Connector to pull data from your PostgreSQL database via an SSH tunnel and compile custom reports. You indicate the data you want by inputting an SQL query. For more information about the PostgreSQL API, visit their website. ([https://www.postgresql.org/docs/](https://www.postgresql.org/docs/ "https://www.postgresql.org/docs/") )

The PostgreSQL SSH connector is a "Database" connector, meaning it retrieves data from databases using a query. In the Data Center, you can access the connector page for this and other Database connectors by clicking **Database** in the toolbar at the top of the window.

You connect to your PostgreSQL database in the Data Center. This topic discusses the fields and menus that are specific to the PostgreSQL SSH connector user interface. General information for adding DataSets, setting update schedules, and editing DataSet information is discussed in [Adding a DataSet Using a Connector](https://domo-support.domo.com/s/article/360042926274?language=en_US "Adding a DataSet Using a Connector").

<Note>
  **Note:** Depending on your network's structure, your IT administrator may need to whitelist any IP addresses necessary for the data connector to retrieve data. Contact your IT administrator for assistance.
</Note>

<table class="mt-responsive-table" data-aura-rendered-by="33:201;a"><tbody><tr><td class="mt-noheading" colspan="1" rowspan="1"><p><b> Primary Use Cases </b></p></td><td class="mt-noheading" colspan="1" rowspan="1"><p> This connector is appropriate for pulling database information into Domo. </p></td></tr><tr><td class="mt-noheading" colspan="1" rowspan="1"><p><b> Primary Metrics </b></p></td><td class="mt-noheading" colspan="1" rowspan="1"><p> N/A </p></td></tr><tr><td class="mt-noheading" colspan="1" rowspan="1"><p><b> Primary Company Roles </b></p></td><td class="mt-noheading" colspan="1" rowspan="1"><ul><li><p> IT </p></li><li><p> Project management </p></li></ul></td></tr><tr><td class="mt-noheading" colspan="1" rowspan="1"><p><b> Average Implementation Time </b></p></td><td class="mt-noheading" colspan="1" rowspan="1"><p> \~10 hours </p></td></tr><tr><td class="mt-noheading" colspan="1" rowspan="1"><p><b> Ease of Use (on a 1-to-10 scale with 1 being easiest) </b></p></td><td class="mt-noheading" colspan="1" rowspan="1"><p> 9 </p></td></tr></tbody></table>

## Best Practices

* Use read-only queries only.
* Use "Replace" instead of "Append."

## Prerequisites

To connect to a PostgreSQL database via an SSH tunnel and create a DataSet, you must have the following:

* The username and password you use to log into your PostgreSQL database
* The name of the PostgreSQL database
* The port number for the PostgreSQL database
* The PostgreSQL database hostname or IP address
* The UNIX server to SSH-tunnel through
* The username and password for the UNIX account
* The SSH port number
* The SSH private key (either DES or RSA)

Before you can connect to a PostgreSQL database, you must also whitelist a number of IP addresses on your database server on the port you want to connect to. For the full list of IP addresses, see [Whitelisting IP Addresses for Connectors](/s/article/360043630093 "Whitelisting IP Addresses for Connectors").

<Note>
  **Note: Domo does not support the SSH keys generated using ssh-keygen. The SSH keys need to be the DES or RSA keys generated by OpenSSL**.
</Note>

## Connecting to Your PostgreSQL Database

This section enumerates the options in the **Credentials** and **Details** panes in the PostgreSQL SSH Connector page. The components of the other panes in this page, **Scheduling** and **Name & Describe Your DataSet**, are universal across most connector types and are discussed in greater length in [Adding a DataSet Using a Connector](https://domo-support.domo.com/s/article/360042926274?language=en_US "Adding a DataSet Using a Connector").

### Credentials Pane

This pane contains fields for entering credentials to connect to your database and SSH server. The following table describes what is needed for each field:

<table border="1" cellpadding="1" cellspacing="1" data-aura-rendered-by="33:195;a"><thead><tr><th colspan="1" rowspan="1"><p> Field </p></th><th colspan="1" rowspan="1"><p> Description </p></th></tr></thead><tbody><tr><td colspan="1" rowspan="1"><p> SSH Server Hostname </p></td><td colspan="1" rowspan="1"><p> Enter the hostname of the UNIX server to SSH-tunnel through. </p></td></tr><tr><td colspan="1" rowspan="1"><p> SSH Username </p></td><td colspan="1" rowspan="1"><p> Enter the SSH username for your UNIX account. </p></td></tr><tr><td colspan="1" rowspan="1"><p> SSH Password </p></td><td colspan="1" rowspan="1"><p> Enter the SSH password username for your UNIX account. </p></td></tr><tr><td colspan="1" rowspan="1"><p> SSH Port </p></td><td colspan="1" rowspan="1"><p> Enter the port number for your UNIX account. </p></td></tr><tr><td colspan="1" rowspan="1"><p> Database Hostname </p></td><td colspan="1" rowspan="1"><p> Enter the host name for the PostgreSQL database. For example: <span class="mt-font-courier-new"><a href="http://db.company.com" rel="noopener" target="_blank"> db.company.com </a></span></p></td></tr><tr><td colspan="1" rowspan="1"><p> SSH Private Key </p></td><td colspan="1" rowspan="1"><p> Enter the SSH private key (either DES or RSA). </p></td></tr><tr><td colspan="1" rowspan="1"><p> Database Name </p></td><td colspan="1" rowspan="1"><p> Enter the PostgreSQL database name. </p></td></tr><tr><td colspan="1" rowspan="1"><p> Database Username </p></td><td colspan="1" rowspan="1"><p> Enter your PostgreSQL username. </p></td></tr><tr><td colspan="1" rowspan="1"><p> Database Password </p></td><td colspan="1" rowspan="1"><p> Enter your PostgreSQL password. </p></td></tr><tr><td colspan="1" rowspan="1"><p> Database Port </p></td><td colspan="1" rowspan="1"><p> Enter your PostgreSQL port number. </p></td></tr></tbody></table>

Once you have entered valid credentials, you can use the same account any time you go to create a new PostgreSQL SSH DataSet. You can manage connector accounts in the **Accounts** tab in the Data Center. For more information about this tab, see [Manage Connector Accounts](https://domo-support.domo.com/s/article/360042926054?language=en_US "Manage Connector Accounts").

### Details Pane

In this pane you create an SQL query to pull data from your database.

<table border="1" cellpadding="1" cellspacing="1" data-aura-rendered-by="33:195;a"><thead><tr><th colspan="1" rowspan="1"><p> Menu </p></th><th colspan="1" rowspan="1"><p> Description </p></th></tr></thead><tbody><tr><td colspan="1" rowspan="1"><p> Query Type </p></td><td colspan="1" rowspan="1"><table border="1"><tbody><tr><td colspan="1" rowspan="1"> Custom Query </td><td colspan="1" rowspan="1"> Enter a customized SQL query with or without parameter to run. </td></tr><tr><td colspan="1" rowspan="1"> Query Builder </td><td colspan="1" rowspan="1"> Build an SQL query by selecting the database table and table columns. </td></tr></tbody></table></td></tr><tr><td colspan="1" rowspan="1"><p> Database Tables </p></td><td colspan="1" rowspan="1"> Select the database table you want to view in your report. This field appears when you select <b> Query Builder </b> as the <b> Query Type </b>. </td></tr><tr><td colspan="1" rowspan="1"><p> Table Columns </p></td><td colspan="1" rowspan="1"> Select all the table columns you want to view in your report. </td></tr><tr><td colspan="1" rowspan="1"><p> Query Helper </p></td><td colspan="1" rowspan="1"> Edit the query if required. </td></tr><tr><td colspan="1" rowspan="1"><p> SQL Query </p></td><td colspan="1" rowspan="1"> Enter the Structured Query Language (SQL) query to select the data you want. </td></tr><tr><td colspan="1" rowspan="1"><p> Incremental Pull </p></td><td colspan="1" rowspan="1"><p> The incremental pull option enables smaller dataset to be pulled from a database table as per variable tag!{column}! and a last value or max value logic option. Dates should include single quotes around the variable tag such as '!{column}!', while integers and decimals can remain without a single quote. </p><p><b> Last value </b>: <b /> populate the variable in the query with the last value for the column to be pulled into Domo. </p><p><b> Max value </b>: <b /> populates the variable in the query with the max value for that column from the last time the dataset ran. </p><p> The syntax for the variable is!{column}!, column being the dataset column to be queried and the incremental pull logic acted against. </p><p><b> Default Value </b> is used in the!{column}! for only the first run of the dataset. </p><p> For example query: Select \* from table where date > '!{date}!' and the max value incremental pull option is selected. The connector uses the max date saved from the previous run for the date column, inserts that date into the query, and then runs the query against the database. All the data with a date greater than the max date would be pulled into Domo. </p></td></tr><tr><td colspan="1" rowspan="1"><p> Default Value </p></td><td colspan="1" rowspan="1"><p> Replaces the!{column}! macro for the first run of the dataset. This field appears when you select <b> Max value </b> or <b> Last value </b> from the <b> Incremental Pull </b> drop-down list. </p></td></tr><tr><td colspan="1" rowspan="1"><p> Fetch Size </p></td><td colspan="1" rowspan="1"><p> Enter the fetch size for the memory performance. If the field is blank, then the default value becomes 400. If it throws out of memory for a value, then decrease the fetch size. </p></td></tr><tr><td colspan="1" rowspan="1"><p> Keep big ints as integers </p></td><td colspan="1" rowspan="1"><p> Select this checkbox to keep big ints as integers. Otherwise, big ints will be converted to floating decimals. </p></td></tr></tbody></table>

## Troubleshooting

* Make sure the appropriate IP addresses are whitelisted (see
  Prerequisites for a list of IP addresses).
* Try decreasing fetch size or leave it empty.
