PostgreSQL
This connector materializes Flow collections into tables in a PostgreSQL database.
It is available for use in the Flow web application. For local development or open-source workflows, ghcr.io/estuary/materialize-postgres:dev
provides the latest version of the connector as a Docker image. You can also follow the link in your browser to see past image versions.
Prerequisites
To use this connector, you'll need:
- A Postgres database to which to materialize, and user credentials. The connector will create new tables in the database per your specification. Tables created manually in advance are not supported.
- At least one Flow collection
Setup
To meet these requirements, follow the steps for your hosting type.
In addition to standard PostgreSQL, this connector supports cloud-based PostgreSQL instances. Google Cloud Platform, Amazon Web Service, and Microsoft Azure are currently supported. You may use other cloud platforms, but Estuary doesn't guarantee performance.
To connect securely, you can either enable direct access for Flows's IP or use an SSH tunnel.
To configure the connector, you must specify the database address in the format host:port
. (You can also supply host
only; the connector will use the port 5432
by default, which is correct in many cases.)
You can find the host and port in the following locations in each platform's console:
- Amazon RDS and Amazon Aurora: host as Endpoint; port as Port.
- Google Cloud SQL: host as Private IP Address; port is always
5432
. You may need to configure private IP on your database. - Azure Database: host as Server Name; port under Connection Strings (usually
5432
). - TimescaleDB: host as Host; port as Port.
Azure Database for PostgreSQL
-
Connect Directly With Azure Database For PostgreSQL: Create a new firewall rule that grants access to the Estuary Flow IP addresses.
-
Connect With SSH Tunneling: Follow the instructions for setting up an SSH connection to Azure Database.
Configuration
To use this connector, begin with data in one or more Flow collections. Use the below properties to configure a Postgres materialization, which will direct one or more of your Flow collections to your desired tables, or views, in the database.
Properties
Endpoint
Property | Title | Description | Type | Required/Default |
---|---|---|---|---|
/database | Database | Name of the logical database to materialize to. | string | |
/address | Address | Host and port of the database. If only the host is specified, port will default to 5432 . | string | Required |
/password | Password | Password for the specified database user. | string | Required |
/schema | Database Schema | Database schema to use for materialized tables (unless overridden within the binding resource configuration) as well as associated materialization metadata tables | string | "public" |
/user | User | Database user to connect as. | string | Required |
/advanced | Advanced Options | Options for advanced users. You should not typically need to modify these. | object | |
/advanced/sslmode | SSL Mode | Overrides SSL connection behavior by setting the 'sslmode' parameter. | string |
Bindings
Property | Title | Description | Type | Required/Default |
---|---|---|---|---|
/additional_table_create_sql | Additional Table Create SQL | Additional SQL statement(s) to be run in the same transaction that creates the table. | string | |
/delta_updates | Delta Update | Should updates to this table be done via delta updates. | boolean | false |
/schema | Alternative Schema | Alternative schema for this table (optional). Overrides schema set in endpoint configuration. | string | |
/table | Table | Table name to materialize to. It will be created by the connector, unless the connector has previously created it. | string | Required |
SSL Mode
Certain managed PostgreSQL implementations may require you to explicitly set the SSL Mode to connect with Flow. One example is Neon, which requires the setting verify-full
. Check your managed PostgreSQL's documentation for details if you encounter errors related to the SSL mode configuration.
Sample
materializations:
${PREFIX}/${mat_name}:
endpoint:
connector:
image: ghcr.io/estuary/materialize-postgres:dev
config:
database: flow
address: localhost:5432
password: flow
user: flow
bindings:
- resource:
table: ${TABLE_NAME}
source: ${PREFIX}/${COLLECTION_NAME}