Skip to main content
ClaudeChatGPT

PostgreSQL

Use this guide to connect PostgreSQL to Wren AI and review the permissions required for stable modeling and query execution.

Plan support

Included in all plans

IP Whitelist for Wren AI Cloud

Wren AI needs to access your PostgreSQL database via the outbound IP address of Wren AI Cloud. Please add the IP address of the Wren AI service to the firewall of your PostgreSQL database.

Scroll to the bottom of the data source connection page to find the IP address.

To add a PostgreSQL connection, click on the PostgreSQL option in the Connect a data source section. connect

Required Permissions

Minimum Permissions Required

To ensure full compatibility and stability, the Postgres user account used by Wren AI requires the following permissions on your target database:

  • SELECT on tables and views
  • CREATE TEMPORARY VIEW
  • DROP VIEW

Wren AI automatically creates and drops temporary views during query execution to support advanced analytics and modeling features.
The views generated by Wren AI will always use unique, system-generated names and will not conflict with or overwrite your existing views.

If your user account is missing any of these permissions, you may encounter errors such as “insufficient privilege” or failures when creating or dropping views.

Connect

Fill in the connection settings: pg_1

Display name

The display name for the database in the Wren AI interface.

Host

Your PostgreSQL database's IP address or domain name.

Port

Your PostgreSQL database port.

Username

The database username for the account that you want to use to connect to your PostgreSQL database.

Password

The password for the username that you use to connect to the database.

Database name

The name of the database you want to connect to.

Click Next to start the connection and go to the next step.

pg_2

Select Tables

All tables of your connected PostgreSQL dataset will be listed in this step. Select which tables you want to use in Wren AI. Each selected table will be created as a data model. See the Modeling documentation to learn more about data models. select_table

Define relationships

Define the relationships among selected tables in this step. If you have defined primary keys and foreign keys in your PostgreSQL dataset, we will list suggested relationships based on that information. If not, you can also add relationships by clicking the Add relationships button on the table blocks. define_relationship_1

Define the following properties in a relationship:

  • From: Select the left side table and column of this relationship.
  • To: Select the right side table and column of this relationship.
  • Relationship Type: Select the type of relationship. define_relationship_2

Find more information about relationships in Modeling - Working with Relationships.

You can also skip this step and finish the connection.