PostgreSQL Integration Guide
Review the following guide for setting up an integration between Manufacturing Connect Edge and a PostgreSQL database.
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:
Note: The version used in this use case for PostgreSQL is 9.6.5.
To add the PostgreSQL Marketplace Application:
- In Manufacturing Connect Edge, navigate to Applications > Marketplace.
- Click Marketplace List and select Default Marketplace Catalog.
- Click the PostgreSQL application tile.
- From the Installation script version drop-down list, select 9.6.5.
- Enter a name and description for the application.
- Update the database name, username, and password as needed.
- Copy the database name, username, and password and store for reference later.
- Click Launch.
- Navigate to Applications > Catalog Apps. The Postgre application appears, pulls the image, and then starts the application. The application shows as running.
- Navigate to Applications > Containers. The postgre application Container is running.
- Copy the IP address for the PostgreSQL application.
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.
After adding the connector, click the toggle in the connector tile to enable it.
If you see a Failed status, you can review the Connector Logs and relevant error messages.
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.
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:
- In Manufacturing Connect Edge, navigate to Applications > Containers.
- Click the Terminal icon next to the PostgreSQL container. The PostgreSQL shell opens.
- 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.
- Enter \l and press ENTER. The list of databases appears in the console.
- Enter \c postgres and press ENTER. You are now connected to database "db-example" as user "postgres" appears.
- Enter \dt and press ENTER. The list of relations appears showing the devicehub schema.
- Enter \d devicehub and press ENTER. The public.devicehub table appears.
- Enter \du and press ENTER. The List of roles appears.
Enter select * from devicehub; and press ENTER. The data for the devicehub table appears.