This guide provides step-by-step instructions to connect your GCP Cloud SQL database to Sequin.

Enable logical replication on GCP Cloud SQL

By default, logical replication is not enabled on GCP Cloud SQL. To enable it, follow these steps:

Enabling replication requires a restart of your database instance.
1

Grant replication permissions

Connect to your database and run the following SQL command to grant replication permissions to your user:

ALTER USER [username] WITH REPLICATION;

Replace [username] with the database user you want to use for replication.

2

Enable pglogical flag

In the Google Cloud Console, navigate to your Cloud SQL instance and follow these steps:

  1. Go to the Configuration tab for your database instance
  2. Click Edit configuration
  3. Under Flags section, add a new flag: cloudsql.enable_pglogical=on
  4. Click Save to apply the changes
3

Restart your database instance

After setting the flag, you need to restart your Cloud SQL instance for the changes to take effect. In the Google Cloud Console:

  1. Go to the Overview tab of your Cloud SQL instance
  2. Click the Restart button at the top of the page
  3. Confirm the restart when prompted

Connect Sequin to your GCP Cloud SQL database

After enabling logical replication on GCP Cloud SQL, you’ll now connect to your database in Sequin.

1

Enter connection details in Sequin

In the Sequin Console, click on the Connect Database button and enter the credentials for your GCP Cloud SQL database:

You can find these connection details in your GCP Cloud SQL instance overview.

  • Host: Your Cloud SQL instance IP address
  • Port: 5432 (default Postgres port)
  • Database: Your database name
  • Username: Your database username (with replication permissions)
  • Password: The password for your database user

Make sure to enable the SSL option for secure connection.

2

Create a replication slot

Connect to your database using the SQL client of your choice and execute the following SQL query to create a replication slot:

SELECT pg_create_logical_replication_slot('sequin_slot', 'pgoutput');

This creates a replication slot named sequin_slot.

3

Create a publication

Next, create a publication to indicate which tables will publish changes to the replication slot. Run the following SQL command:

CREATE PUBLICATION sequin_pub FOR TABLE table1, table2, table3;

If you want to publish changes from all tables, you can use:

CREATE PUBLICATION sequin_pub FOR ALL TABLES;
4

Enter the replication slot details in Sequin

Back in the Sequin Console, enter the name of the replication slot (e.g. sequin_slot) and publication (e.g. sequin_pub) you just created. Then, name your database and click Create Database.

Create a consumer

With your GCP Cloud SQL database connected to Sequin via a replication slot and publication, Sequin is now detecting changes to your tables. Now create a consumer to process your data changes and send them to your application.

Click the Add a consumer button and select your GCP Cloud SQL database as the source. Follow the instructions in our quickstart guide to complete the process.

Next steps

With your GCP Cloud SQL database connected to Sequin, you can now:

  • Set up filters to capture specific changes.
  • Use Sequin’s observability features to monitor and debug your data flows.
  • Explore Sequin’s replay and backfill features for historical data processing.

For more information on these features, check out our core concepts documentation.

Was this page helpful?