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

# PostgreSQL (Native)

export const CommonDatasourceMoreInformation = ({datasource = "the data source", advancedurl = "", siteName = "CData Sync", driverVersion = ""}) => {
  return <>
      <p>
        For more information about interactions between {siteName} and {datasource}, see{' '}
        <a href={`https://cdn.cdata.com/help/${advancedurl}${driverVersion}/synch/default.htm`}>
          {datasource} Connector for {siteName}
        </a>.
      </p>
    </>;
};

export const CommonDatasourceAddConnector = ({datasource = "the data source", title = "the connector", destination = false, siteNameShort = "Sync"}) => {
  return <>
      <p>
        To enable {siteNameShort} to use data from {datasource}, you first must add the
        connector, as follows:
      </p>
      <ol>
        <li>Open the <strong>Connections</strong> page of the {siteNameShort} dashboard.</li>
        <li>Click <strong>Add Connection</strong> to open the <strong>Select Connectors</strong> page.</li>
        <li>
          Click the <strong>{destination ? "Destinations" : "Sources"}</strong> tab and locate
          the <strong>{title}</strong> row.
        </li>
        <li>
          Click the <strong>Configure Connection</strong> icon at the end of that row to open
          the <strong>New Connection</strong> page. This action opens the{' '}
          <strong>Add Connection</strong> dialog box.
          <br />
          <strong>Note:</strong> If the <strong>Configure Connection</strong> icon is not
          available, click the <strong>Download Connector</strong> icon to install
          the {title} connector.
        </li>
        <li>Enter a name for your connection in the <strong>Add Connection</strong> dialog box.</li>
        <li>Click <strong>Add</strong> to open the <strong>Settings</strong> tab for your connector.</li>
      </ol>
      <p>
        For more information about installing new connectors, see{' '}
        <a href="../connections">Connections</a>.
      </p>
    </>;
};

export const CommonDatasourceIntroSource = ({datasource = "the data source", siteName = "CData Sync"}) => {
  return <p>
      You can use the {datasource} connector from the {siteName} application to capture data
      from {datasource} and move it to any supported destination. To do so, you need to add
      the connector, authenticate to the connector, and complete your connection.
    </p>;
};

export const driverVersion = "M";

export const siteNameShort = "Sync";

export const siteName = "CData Sync";

export const datasource = "PostgreSQL";
export const pageTitle = "PostgreSQL (Native)";
export const advancedurl = "FP";

<CommonDatasourceIntroSource datasource={datasource} siteName={siteName} />

<Note>This connection can be used <u>only as a source</u> for the **Change Data Capture** job type.</Note>

## Prerequisites

Before you add and set up the {datasource} source connector, you need to set up {datasource} for change data capture (CDC), as explained in the following sections.

### Minimum Requirements

Before you set up {datasource} for CDC, ensure that you have the following minimum requirements:

* **{datasource} Version:** Version 12 or later

  <Note>Only databases with the UTF-8 character encoding are supported for CDC. Strings that contain extended ASCII characters might not be processed correctly during the incremental replication.</Note>

* **User Privileges:** LOGIN and REPLICATION (the minimum privileges that are required for connecting to PostgreSQL and reading the replication slot)

### Set Up PostgreSQL for CDC

Perform the following steps to enable logical replication, specify which tables to replicate, and create a logical replication slot for {siteNameShort}.

1. Ensure that the `wal_level` parameter is set in your {datasource} database, as follows:

   1. Verify the current `wal_level` setting in {datasource} by submitting the following query:

      ```
      SHOW wal_level;
      ```

   2. Set the `wal_level` parameter to enable logical replication in either of the following ways:

      **Method 1:** Execute the following command:

      `ALTER SYSTEM SET wal_level = logical;`

      <br />

      <br />

      **Method 2:** Set `wal_level = logical` manually in your {datasource} file, as shown below:

      ```
      # REPLICATION
      wal_level = logical   
      ```

   <Note>Regardless of which method you use, you **must restart the {datasource} database** for the changes to take effect.</Note>

2. Create a publication to specify which tables to replicate.

   ```
   CREATE PUBLICATION cdatasync_pub1 FOR TABLE table1, table2, ...;
   ```

   You can also create a publication for all tables in the database, as shown below.

   ```
   CREATE PUBLICATION cdatasync_pub1 FOR ALL TABLES;
   ```

   <Note>SUPERUSER privileges are required when you create a publication for all tables.</Note>

3. Create a logical replication slot for {siteNameShort} by submitting the following SELECT statement:

   ```
   SELECT pg_create_logical_replication_slot('SlotName', 'pgoutput');
   ```

   <Note>When you create the logical replication slot, you must use the `pgoutput` plugin.</Note>

## Add the PostgreSQL Connector

<CommonDatasourceAddConnector datasource={datasource} title={pageTitle} destination={false} siteNameShort={siteNameShort} />

## Authenticate to PostgreSQL

After you add the connector, you need to set the required properties.

* **Host:** Enter the host name or IP of the server that hosts the {datasource} database. The default server value is **localhost**.
* **Port:** Enter the port number of the server that hosts the {datasource} database. The default port value is **5432**.
* **Database:** Enter the name of the database that to which you want to connect when you connect to the {datasource} server. The default database is **postgres**.
* **User:** Enter the username that you use to authenticate to your {datasource} account.
* **Password:** Enter the password that you use to authenticate to your {datasource} account.

## Complete Your Connection

To complete your connection:

1. Define advanced connection settings on the **Advanced** tab. (In most cases, though, you should not need these settings.)
2. Click **Create & Test** to create your connection.

## More Information

<CommonDatasourceMoreInformation datasource={datasource} advancedurl={advancedurl} siteName={siteName} driverVersion={driverVersion} />
