This article describes how to create and maintain connections to your PostgreSQL database.
Before you can write your transformed data to a table in PostgreSQL, you should first establish a connection to your PostgreSQL database.

Create a PostgreSQL connection

Simple example

A PostgreSQL connection can be created as follows:
CONNECTION_STRING = 'jdbc:postgresql://'
USER_NAME = 'your username'
PASSWORD = 'your password'
When using PostgreSQL, it is not necessary to specify the database itself in the connection string.
For the full list of connection options with syntax and detailed descriptions, see PostgreSQL connection with SQL.
Once you've created your connection, you are ready to move on to the next step of building your data pipeline: reading your data into SQLake with an ingestion job.

Alter a PostgreSQL connection

Certain connection options are considered mutable, meaning that in some cases, you can run a SQL command to alter an existing PostgreSQL connection rather than create a new one.
To change the database you are connecting to but keep everything else the same without having to create an entirely new connection, you can run the following command:
ALTER POSTGRES CONNECTION my_postgres_connection
SET CONNECTION_STRING = 'jdbc:postgresql://'
To check which connection options are mutable, see PostgreSQL connection with SQL.

Drop a PostgreSQL connection

If you no longer need a connection, you can easily drop it with the following SQL command:
DROP CONNECTION my_postgres_connection;
However, note that if there are existing tables or jobs that are dependent upon the connection in question, the connection cannot be deleted.
For more details, see DROP CONNECTION.
Last modified 5mo ago