How-To Guides
Integration Guides

PostgreSQL Integration Guide

10min

Review the following guide for setting up an integration between Manufacturing Connect Edge and a PostgreSQL database.

User Scenario

In this guide you will deploy a PostgreSQL database container from Manufacturing Connect Edge and then integrate with the database using the DB-PostgreSQL Server connector. For your specific scenario you may use an external PostgreSQL Server database to set up the integration.

For external PostgreSQL databases, refer to the following links to learn more:

Step 1: Add Device



Step 2: Add Tags



Step 3: Add PostgreSQL Marketplace Application

Note: The version used in this use case for PostgreSQL is 9.6.5.

To add the PostgreSQL Marketplace Application:

  1. In Manufacturing Connect Edge, navigate to Applications > Marketplace.
  2. Click Marketplace List and select Default Marketplace Catalog.
  3. Click the PostgreSQL application tile.
  4. From the Installation script version drop-down list, select 9.6.5.
  5. Enter a name and description for the application.
  6. Update the database name, username, and password as needed.
  7. Copy the database name, username, and password and store for reference later.
  8. Click Launch.
  9. Navigate to Applications > Catalog Apps. The Postgre application appears, pulls the image, and then starts the application. The application shows as running.
  10. Navigate to Applications > Containers. The postgre application Container is running.
  11. Copy the IP address for the PostgreSQL application.

Step 4: Add the DB - PostgreSQL Connector

Follow the steps to Add a Connector and select the DB - PostgreSQL provider.

Configure the following parameters.

  • Name: Enter a name for the connector.
  • Hostname: Paste the IP address you copied in Step 3.
  • Port: The PostgreSQL Server port. The default value is 5432.
  • Username: Paste the username configured in Step 3.
  • Password: Paste the password configured in Step 3.
  • Database: Paste the database name configured configured in Step 3.
  • Table: Enter devicehub. If you are sending data to an existing table, use the corresponding name.
  • Show Mapping: If you want to send data to a custom table, select this checkbox and unselect Create table. See Work with Tables in SQL Connectors (Create Table and Show Mapping) to learn more. To add key/value pairs for the custom table, see Configure Key/Value Pairs.
  • Create table: If you want to send data to an existing table in the default format, or you want to create a new table in the default format, select this checkbox and unselect Show Mapping. See Work with Tables in SQL Connectors (Create Table and Show Mapping) to learn more.
  • Commit timeout: Enter the transaction commit timeout in (ms).
  • Max transaction size: Enter the maximum number of messages before a transaction is committed, regardless of timeout parameter.
  • Throttling limit: The maximum number of messages per second to be processed. The default value is zero, which means that there is no limit.
  • Persistent storage: When enabled, this will cause messages to undergo a store-and-forward procedure. Messages will be stored within Manufacturing Connect Edge when cloud providers are online. 
  • Queue Mode: Select the queue mode as lifo (last in first out) or fifo (first in first out). Selecting lifo means that the last data entry is processed first, and selecting fifo means the first data entry is processed first.

Step 5: Enable the Connector

After adding the connector, click the toggle in the connector tile to enable it.

Document image


If you see a Failed status, you can review the Connector Logs and relevant error messages.

Step 6: Create Topics for Connector

You will now need to import the tags created in Step 2 as topics for the PostgreSQL connector. The topics will be created as outbound topics.



After adding all required topics, navigate to the Integration overview page and ensure the connector is not disabled and still shows a CONNECTED status.

Step 7: Enable Topics



Step 8: Make PostgreSQL Queries

You can now verify that you can view data through the terminal command window.

Update the credentials, database name, and table name to your specific configurations.

To make queries in the container terminal:

  1. In Manufacturing Connect Edge, navigate to Applications > Containers.
  2. Click the Terminal icon next to the PostgreSQL container. The PostgreSQL shell opens.
  3. From the PostgreSQL container terminal, enter psql -h locahost -U postgres and press ENTER. The psql (13.2 (Debian 13.2-1.pgdg100+1)) version number appears.
  4. Enter \l and press ENTER. The list of databases appears in the console.
  5. Enter \c postgres and press ENTER. You are now connected to database "db-example" as user "postgres" appears.
  6. Enter \dt and press ENTER. The list of relations appears showing the devicehub schema.
  7. Enter \d devicehub and press ENTER. The public.devicehub table appears.
  8. Enter \du and press ENTER. The List of roles appears.
  9. Enter select * from devicehub; and press ENTER. The data for the devicehub table appears.

    PostgreSQL connector messages
    PostgreSQL connector messages