Overview
It is possible to establish a robust and secure connection with a PostgreSQL database using You can use a PostgreSQL database with the Tag Historian feature. The steps to achieve this involve renaming databases, creating and testing the PostgreSQL connection, configuring tags and tasks, and writing specific queries for select, insert, update, and delete operations. :
- Rename Databases.
- Create and Test the PostgreSQL Connection.
- Configure Tags and Tasks.
- Write Specific Queries for Select, Insert, Update, and Delete Operations.
On this page:
Table of Contents | ||||
---|---|---|---|---|
|
Configuration PostgreSQL Via Tag Historian
To configure Postgre Follow the steps below to configure PostgreSQL using Tag Historian, follow the steps below.
Click Test and- Access Datasets > / DBs.
- Rename the SQLite database TagHistorian to TagHistorian2 or another name.any other name. You should rename it because the system will use the TagHistorian name to configure the Postgre SQL.
- In DBsNow, click the plus icon to create a new Database Connection.
- Enter the name In the Name field, enter TagHistorian.
- Choose PostgreSQL Data Provider as the provider Provider for this the database.
- Click OK.
- In the data grid, click the Connection String column of the newly created row.
Configure the connection. For the Server
parameter withfield, enter the IP address of the
Postgre Server,PostgreSQL server. In addition, you need to provide the Port,
and the name of the Database.
Database name, and User ID. After filling in all fields, click Test to ensure the connection with the
PostgreSQL server is working correctly.
Configuration Example
This example presents necessary steps to connect and start using a PostgreSQL DB. To run the example, it is necessary to For the purpose of this example we have created objects in other modules of the platform, the following is list presenthing them.
In Datasets > Queries some queries were created, they are:. Below you find a list of modules used and the necessary configurations.
In Datasets / Queries you need to create the queries below. Access Datasets Queries to learn how to configure queries.
- QuerySelect
- QueryInsert
- QueryDelete
- QueryUpdate
In Unified Namespace
> Tags/ Tags, we created some tags
for this example, they areto save values in the database. To learn how to create and configure tags, access Unified Namespace. The created tags are described below:
- Integer01, Integer02, and Integer03
- are used to send values to the
- PostgreSQL database.
- TriggerUpdate, TriggerSelect, TriggerInsert, and TriggerDelete
- are used to trigger
- script tasks created for the example.
- QuerySelect
- is used to receive the result of the Select query.
In Historian
>/ Historian Tags
configured, configure the Integer01, Integer02, and Integer03
Tagstags to Table1. Remember that the PostgreSQL connection must be configured to work with Tag Historian, which is standard
and is configured to use PostgreSQL.
In
Scripts > Tasks we created some tasks toaddition to the above configuration, you need to access Scripts / Tasks and create tasks for Select, Delete, Update, and Insert,
and configuredconfiguring the Trigger column with the marks created
before. The scripts are as followsearlier. Below, you will find all required scripts:
Select Query
Code Block language c# @Tag.QuerySelect = @Dataset.Quey.QuerySelect.SelectCommand(); @Info.Trace("Select OK:" + @Tag.QuerySelect);
Insert Query
Code Block language c# int i = @Dataset.Query.QueryInsert.ExecuteCommand(); @Info.Trace("Insert OK:" + i);
Update Query
Code Block language c# int i = @Dataset.Query.QueryUpdate.ExecuteCommand(); @Info.Trace("Update OK:" + i);
Delete query:
Code Block language c# int i = @Dataset.Query.QueryDelete.ExecuteCommand(); @Info.Trace("Delete OK:" + i);
Now, we After finishing the configuration and creating the scripts, you can run the project and give some provide different values to the Tags , thus, within pgAdmin 4 we can see that Table 1 was created with values that were given.
created. Thus, if you access the PostgreSQL Server, you can access the created Table1. You can also check that all values you provided are within Table1 due to the execution of previously created queries.
Thus, we trigger tasks through Trigger Tags, all Queries were successfully performed and our Table within Postgre is updated with the Queries we created before.
In this section...
Page Tree | ||||
---|---|---|---|---|
|