Skip to main content

PostgreSQL: Export guide

Export your Funnel data to a PostgreSQL database, including managed services such as Amazon RDS and Supabase.

Export your Funnel data to a PostgreSQL database to store, query and report on it with SQL. The export works with self-managed PostgreSQL servers and with managed services such as Amazon RDS, Google Cloud SQL, Azure Database for PostgreSQL and Supabase. For general guidance on warehouse exports, read the data warehouse export best practices.

​

Before you begin

  • You're on a Business or Enterprise plan, or in a trial.

  • You have a PostgreSQL database that Funnel can reach over the internet using IPv4.

  • Your database accepts SSL connections, because Funnel only connects using SSL.

  • You can create database users and grant permissions, or someone who can is helping you.

​

Set up the PostgreSQL export

Prepare your database

Funnel needs a database user that can create tables, add columns, delete rows and insert rows in the destination schema. We recommend a dedicated user for Funnel. If you already have a user with these permissions, skip to Let Funnel connect to your database.

​

Create a user, and optionally a database and schema, for Funnel. Replace choose-a-strong-password with a secure password.

-- Create a dedicated user for Funnel
CREATE USER funnel_export WITH PASSWORD 'choose-a-strong-password';
-- Optional: create a database
CREATE DATABASE funnel_database;
-- Connect to the database (psql)
\c funnel_database
-- Create a schema owned by the Funnel user
CREATE SCHEMA IF NOT EXISTS funnel AUTHORIZATION funnel_export;

If you use an existing schema instead of one the Funnel user owns, grant the user access to the schema.

-- Allow the user to connect to the database
GRANT CONNECT ON DATABASE funnel_database TO funnel_export;
-- Allow the user to use the schema and create tables
GRANT USAGE, CREATE ON SCHEMA funnel TO funnel_export;

Note: Let Funnel create the destination table on the first run. PostgreSQL only lets the table owner add columns, and Funnel adds a column each time you add a field to the export. So if you export to an existing table, the Funnel user must own the table.

Let Funnel connect to your database

  1. If a firewall, security group or pg_hba.conf limits incoming connections, allowlist Funnel's IP addresses.

    ​

    • app.funnel.io: 34.195.70.7, 34.205.117.228 and 44.214.249.94

    • app.eu.funnel.io: 35.156.15.138, 35.158.190.91 and 63.180.53.242

    ​

  2. Make sure your database host name resolves to an IPv4 address. Funnel can't connect to a host that only has an IPv6 address.

​

Connect to Supabase

The direct Supabase host, db.<project-ref>.supabase.co, is IPv6-only unless you turn on the Supabase IPv4 add-on. To connect without the add-on, use the Supabase Session pooler:

Setting

Value

Host

aws-0-<region>.pooler.supabase.com

Port

5432

Username

Your database user followed by your project reference, for example funnel_export.<project-ref>

Password

The password of that database user

Database

Your database name

Find these values in your Supabase dashboard under Connect > Session pooler. Funnel doesn't support the Transaction pooler on port 6543. To use the direct host instead, turn on the IPv4 add-on under Project Settings > Add-ons in Supabase.

​

​

Create the export in Funnel

Have these destination details ready:

Setting

What to enter

Host

The host name of your PostgreSQL server, for example mydb.abc123.us-east-1.rds.amazonaws.com.

Port

The PostgreSQL port, usually 5432.

Database

The database name, for example funnel_database.

Schema name

The schema Funnel writes to, for example funnel. Use public if you don't have a dedicated schema.

Table name template

The destination table, for example funnel_data. Use only letters, numbers and underscores. Don't include year, month or date placeholders.

  1. In Funnel, go to Export and click + Create Export.

    ​

  2. Search for and select PostgreSQL.

    ​

  3. Add a connection for the database user you created earlier. Enter the username and password of that user.

    ​

  4. Enter the destination details: Host, Port, Database, Schema name and Table name template.

    ​

  5. Choose the data, date range and schedule, then click Save.

    ​

  6. Click Run job to send your data right away.

​

What to expect

When the run finishes, your data is in the destination table, and you can query it with SQL. Funnel then updates the table on every scheduled run.

​

How Funnel updates the table

  • New table: If the table doesn't exist, Funnel creates it on the first run.

  • New fields: When you add a field to the export, Funnel adds a column for it.

  • Removed fields: When you remove a field, Funnel keeps the column but leaves it empty in new rows. You can drop the column in PostgreSQL if you no longer need it.

  • Exports with a date range: On each run, Funnel deletes the rows in the export's date range and inserts fresh data for that period. Funnel doesn't update rows outside the date range, but they stay in the table. For example, with Last 6 months, rows older than six months stay from earlier runs.

  • Exports without a date field: On each run, Funnel empties the table and reloads every row.

​

Funnel doesn't append rows or update single rows. Don't edit data in the export table, because the next run can overwrite your changes. To transform the data, create a PostgreSQL view or copy the data into another table.

​

Data types

Funnel field type

PostgreSQL column type

Text

TEXT

Number (decimal)

DOUBLE PRECISION

Number (integer)

INTEGER

Date

DATE

Date and time

TIMESTAMP

Did this answer your question?