> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zwiron.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PostgreSQL Connector

> Sync PostgreSQL with WAL CDC, incremental, or full refresh to Snowflake, BigQuery, and more via Zwiron.

<Info>
  **Live — enterprise connector.** Fully supported today (SAT-validated). One of Zwiron's five production connectors: PostgreSQL, MySQL, MongoDB, Snowflake, BigQuery.
</Info>

PostgreSQL is one of the most widely used open-source relational databases. Zwiron supports Postgres as both a source and destination, with full support for Full Refresh, Incremental, and CDC (Change Data Capture) sync modes.

***

## Supported sync modes

| As source | Full Refresh | Incremental | CDC |
| --------- | ------------ | ----------- | --- |
|           | ✅            | ✅           | ✅   |

| As destination | Write modes             |
| -------------- | ----------------------- |
|                | Append, Upsert, Replace |

***

## Connection details

When creating a Postgres connection in Zwiron, you'll need:

| Field    | Description                                                                                                                                                                                             |
| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Host     | Hostname or IP address of your Postgres server                                                                                                                                                          |
| Port     | Default: `5432`                                                                                                                                                                                         |
| Database | The database name to connect to                                                                                                                                                                         |
| Username | The Postgres user Zwiron will use                                                                                                                                                                       |
| Password | The user's password. If you paste a URI and the password has `@`, `%`, `:`, `/`, etc., [percent-encode them](/connectors/databases/mysql#passwords-with-special-characters) (same rules as MySQL URIs). |
| SSL mode | `require`, `verify-ca`, or `verify-full` (recommended for production)                                                                                                                                   |

***

## Permissions

### For a source (read-only)

Create a dedicated user with read access:

```sql theme={null}
-- Create the user
CREATE USER zwiron WITH PASSWORD 'your_password';

-- Grant access to your schema
GRANT USAGE ON SCHEMA public TO zwiron;

-- Grant read access to all existing tables
GRANT SELECT ON ALL TABLES IN SCHEMA public TO zwiron;

-- Grant read access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO zwiron;
```

### For a destination (read-write)

```sql theme={null}
CREATE USER zwiron WITH PASSWORD 'your_password';

GRANT USAGE, CREATE ON SCHEMA public TO zwiron;
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO zwiron;
ALTER DEFAULT PRIVILEGES IN SCHEMA public
  GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO zwiron;
```

### For CDC (additional permissions)

```sql theme={null}
-- Must have REPLICATION attribute
ALTER USER zwiron WITH REPLICATION;

-- Create a publication for the tables you want to replicate
CREATE PUBLICATION zwiron_pub FOR ALL TABLES;
-- Or for specific tables:
-- CREATE PUBLICATION zwiron_pub FOR TABLE orders, customers;
```

***

## Enabling CDC

CDC requires logical replication to be enabled on your Postgres instance.

### Step 1 — Enable logical replication

Add to `postgresql.conf`:

```
wal_level = logical
max_replication_slots = 5
max_wal_senders = 10
```

Restart Postgres after making this change.

### Step 2 — Verify

```sql theme={null}
SHOW wal_level;  -- should return "logical"
```

### Step 3 — Create a replication slot (optional)

Zwiron creates the replication slot automatically when CDC is enabled. If you want to create it manually:

```sql theme={null}
SELECT pg_create_logical_replication_slot('zwiron_slot', 'pgoutput');
```

### Step 4 — Configure CDC in Zwiron

When creating a pipeline:

1. Select Postgres as your source connection
2. Choose **CDC** as the sync mode
3. Zwiron will use the publication and create a replication slot automatically

***

## Notes for managed Postgres

### Amazon RDS for PostgreSQL

Logical replication requires `rds.logical_replication = 1` in your parameter group. The `rds_replication` role must be granted to the Zwiron user:

```sql theme={null}
GRANT rds_replication TO zwiron;
```

### Amazon Aurora PostgreSQL

Same as RDS. Set `rds.logical_replication = 1` in the cluster parameter group.

### Google Cloud SQL for PostgreSQL

Enable the `cloudsql.logical_decoding` flag in your Cloud SQL instance settings. Grant replication to the user:

```sql theme={null}
ALTER USER zwiron WITH REPLICATION;
```

**Hosted mode networking:** Add **all** of [Zwiron's static egress IPs](/concepts/network-access) under Cloud SQL **Authorized Networks**. Private IP alone does not work for Hosted mode — use Public IP plus the full allowlist.

### Supabase

Logical replication is enabled by default. Create a publication and grant replication to the Zwiron user.

***

## Related guides

* [Postgres CDC to Snowflake](/guides/postgres-cdc-to-snowflake)
* [Hosted vs agent](/guides/hosted-vs-agent)
* Product page: [Postgres → Snowflake](https://zwiron.com/integrations/postgres-snowflake)

## Troubleshooting

<AccordionGroup>
  <Accordion title="CDC slot is not advancing / replication lag growing">
    This usually means the replication slot is not being consumed. Check that the agent is running and the CDC job is active. If the agent was offline for an extended period, the slot may need to be dropped and recreated.
  </Accordion>

  <Accordion title="Permission denied for table">
    Ensure the Zwiron user has SELECT granted on the specific table, and that default privileges are set for future tables.
  </Accordion>

  <Accordion title="Connection refused">
    Ensure `pg_hba.conf` allows the agent's IP address to connect. Add a rule like:

    ```
    host  all  zwiron  <agent-ip>/32  md5
    ```
  </Accordion>
</AccordionGroup>
