PostgreSQL
PostgreSQL, or Postgres, is an open source relational database management system that uses and extends the SQL language. It is free to use, highly extensible, and tries to conform with the SQL standard.
This document walks you through setting up Postgres to use as a source data Data Store in DeltaStream.
Setting up PostgreSQL
Prerequisites
Create a user in the PostgreSQL instance (see PostgreSQL documentation).
Important If you're creating a CDC pipeline backed by a PostgreSQL source data store, review these additional setup instructions.
Adding PostgreSQL as a DeltaStream Data Store
Open DeltaStream. In the lefthand navigation, click Resources (
). The Resources page displays, with the Data Stores tab active.
Click + Add Data Store, and from the list that displays click PostgresSQL. The Add Data Store window displays, with Postgres-specific fields you must complete.
Postgres Store Details Enter the following information:
Store Name – A name to identify your DeltaStream data store (See Data Store).
Store Type – POSTGRESQL.
URI – URI for the PostgreSQL database with
/<database_name>
appended. For example, given a postgres URI ofmy.postgresql.uri
and an open port on the database of5432
, to connect DeltaStream to the demo database the URI would display as:postgresql://my.postgresql.uri:5432/demo
Username – Username associated with the PostgreSQL database user DeltaStream should assume.
Password – The password associated with the username.
Click Add to create and save the data store.
Inspect the PostgreSQL Data Store
In the lefthand navigation, click Resources (
). This displays a list of the existing data stores.
Click your PostgresSQL data store (in this case, Postgres_Test_Store). The Postgres data store page opens with the Schemas tab active. A list displays of the existing schemas in your PostgreSQL database.
(Optional) Create a new schema. To do this:
Click + Add Schema. When the Add Schema window opens, enter a name for the new schema and then click Add. Your new schema displays in the entities list.
Adding a Postgres data Store Schema
To view the tables in a schema, click a schema name.
To view a sample of rows from that table, click a table in a schema and then click Print.
Postgres Schema Details
Process PostgreSQL CDC Data and Sink to Kafka
To follow the next few steps, you must already have a PostgreSQL data store labeled psql_store
. You also must have a Kafka data store labeled kafka_store.
Define a DeltaStream stream as your source data from PostgreSQL. Then write a query to process this data and sink it to a Kafka topic.
Defining a DeltaStream Stream on a PostgreSQL Table
In this step, you create a stream called pageviews_cdc
that is backed by data in a PostgreSQL table. This stream represents change data capture (CDC) events from the PostgreSQL table.
First, print the data for your source, which is the pageviews
PostgreSQL table. To print sample rows from the table in DeltaStream, inspect your data store and navigate to the table you wish to print. (For more details, see PostgreSQL).
Below is an example of how to create a stream on your pageviews
data. The fields match the Debezium standard; any insert, delete, or update to the pageviews
table becomes an event for your pageviews_cdc
stream.
Write a CSAS (CREATE STREAM AS SELECT) Query to Sink Data into Kafka
In the lefthand navigation, click Workspace (
).
In the SQL pane of your workspace, write the CREATE STREAM AS SELECT (CSAS) query to ingest from
pageviews_cdc
and output to a new stream labeledpageviews_cdc_sink
. To represent a feed of upsert events, this query filters for records whoseop
field isCREATE
orUPDATE
.
Click Run.
In the lefthand navigation, click Queries (
) to view existing queries, including the query from step 2, above. Important It can take a small amount of time for the query to transition into the Running state. Refresh you screen occasionally until you see the query transition into the Running state.
Verify that the query is properly working. To do this, write an interactive SELECT query.

Last updated