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

# PostgreSQL

## Overview

Stigg's integration with PostgreSQL allows you to export your product catalog, customer, and subscription data directly to your PostgreSQL database for custom reporting and analysis.

<Note>
  Stigg's native data export integrations are included in the Scale plan, and are also available as an optional add-on to the Growth plan. See Stigg's pricing for more details.
</Note>

<Card title="View the full entity schema" icon="sitemap" href="./schema">
  See every table and column exported to your destination, organized by entity group.
</Card>

## Setting up the integration

### Prerequisites

You'll need a PostgreSQL instance with a database and a user that has permission to create tables and write data in the target schema. PostgreSQL 13 and above is fully supported; PostgreSQL 12 is supported on a best-effort basis.

If your database is protected by security groups or other firewall settings, you'll need Stigg's static IP (shown in the connect form) to complete the first step below.

<Steps>
  <Step title="Allow access">
    Configure your firewall or security group to permit:

    * Incoming connections to your host and port (usually `5432`) from Stigg's static IP
    * Outgoing connections from ports `1024`–`65535` to that same IP

    <Note>
      If your database isn't accessible from the public internet, SSH tunneling through a bastion host is supported. Allow inbound SSH (port `22`) from Stigg's static egress IP on the bastion host, create an SSH user with Stigg's public key in `~/.ssh/authorized_keys` ([contact Stigg support](mailto:support@stigg.io) for the key), and grant the bastion host's IP access to the database port in place of the static egress IP. Provide the bastion host address, port, and username in the connection form.
    </Note>
  </Step>

  <Step title="Create a writer user">
    Create the database user Stigg will connect as, and grant it permission to create tables and write to the target database:

    <CodeGroup>
      ```sql Create user theme={null}
      CREATE USER <username> PASSWORD '<some-password>';
      GRANT CREATE, TEMPORARY ON DATABASE <database> TO <username>;
      ```
    </CodeGroup>

    If you're pre-creating the schema rather than letting Stigg create it on first sync, also grant:

    <CodeGroup>
      ```sql Grant on pre-created schema theme={null}
      GRANT ALL ON SCHEMA <schema> TO <username>;
      ```
    </CodeGroup>

    <Warning>
      Avoid special characters (`@`, `[`, `]`, `/`, `?`, `#`, `"`, `\`, `+`, spaces, `&`, `:`, `%`) in the username and password — they can break connection string parsing.
    </Warning>
  </Step>

  <Step title="Connect Stigg with PostgreSQL">
    In [Stigg](https://app.stigg.io/), navigate to **Integrations > Apps > PostgreSQL**.

    Enter the following information in the connection form:

    | Field    | Description                                          |
    | -------- | ---------------------------------------------------- |
    | Host     | The hostname or IP address of your PostgreSQL server |
    | Port     | The port PostgreSQL listens on. Defaults to `5432`.  |
    | Database | The name of the target database                      |
    | Schema   | The schema where Stigg will create and sync tables   |
    | Username | The PostgreSQL user Stigg will authenticate as       |
    | Password | The password for the PostgreSQL user                 |

    Click **Test & connect**.
  </Step>

  <Step title="Select entities to export">
    After entering your connection details, expand the **Entities to export** section to choose which entity groups to include in the sync. All groups are selected by default.

    See [Exported entities](./overview#exported-entities) for a description of each group.
  </Step>
</Steps>


## Related topics

- [Exported entities](/documentation/importing-and-exporting-data/export/overview.md#exported-entities)
- [Sync process, schedule, manual sync, and sync history](/documentation/importing-and-exporting-data/export/overview.md#sync-process)
