# PostgreSQL

## PostgreSQL Database Data Import

You can quickly import data from your PostgreSQL Database into Exploratory.

### 1. Create a Connection to use

Create a connection following [this instruction](https://docs.exploratory.io/data_import/database-data/connection).

* Whether the connection is SSL or not is automatically detected.

### 2. Open PostgreSQL Import dialog

Click '+' button next to 'Data Frames' and select 'Database Data'.

![](/files/-M4oN-qBMezITjny_pQQ)

Click PostgreSQL to select.

![](/files/-M4oNAP9G3lWC5ppN1PQ)

### 3. Preview and Import

Click Preview button to see the data back from your PostgreSQL db.

![](/files/-M4oNAPBx4_aTFq4j4bc)

If it looks ok, then you can click 'Import' to import the data into Exploratory.

### 4. Using Parameters in SQL

First, click Parameter link on the SQL Data Import Dialog.

![](/files/-M4oN2yAtTsqxNt3r0_M)

Second, define a parameter and click Save button.

![](/files/-M4oN2yC4K_GmMFFjzoo)

Finally, you can use @{} to surround a variable name inside the query like below.

```
select *
from airline_2016_01
where carrier = @{carrier}
```

If you type @ then it suggests parameters like below.

![](/files/-M4oN2yEXevqQptAWUEl)

Here's a [blog post](https://exploratory.io/note/kanaugust/An-Introduction-to-Parameter-in-Exploratory-WCO4Vgn7HJ) for more detail.

### 5. Number of rows

From performance point of view, we no longer show actual number of rows which can be only fetched by executing whole query again.

![](/files/-M4oN66xWkcCxqo19jUZ)

If you still want to show the actual number of query for your query, you can do so by setting System Configuration.

![](/files/-M4oN66zCHttnANqtQHx)

Then set "Yes" For "Show Actual Number of Rows on SQL Data Import Dialog"

![](/files/-M4oN670aVGCuTHA4oG4)

This will show you Actual Number of Rows like below.

![](/files/-M4oN6725Fzzj5A208wn)

### 6. AWS Security Group Setup (Only for Amazon RDS)

![](/files/-M4oN8VdKzRdaPgEHSxA)

If you are using Amazon RDS as your MySQL database, and encounter a database connection error, please go to AWS console and make sure you added your client PC's IP address to an inbound rule for your DB Security Group associated with the MySQL database instance.

## 7. Known Issues for geometry column.

When you try to import data from PostgreSQL instance, you might get the below error if your SQL query contains columns whose data type is geometry which is not supported in Exploratory.

Error : No method asJSON S3 class: pq\_geometry

Please refer to [this community post](https://community.exploratory.io/t/error-no-method-asjson-s3-class-pq-geometry-is-raised-when-try-to-import-data-from-postgresql/2102) for the workaround.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.exploratory.io/data_import/database-data/postgresql.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
