Overview
It is possible to establish a robust and secure connection with a You can use PostgreSQL database using the Tag Historian feature. The steps to achieve this involve renaming databases, creating :
- Rename databases.
- Create and testing 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 with field, enter the IP of the Postgre Server. In addition, you need to provide the Port, Database name, and the name of the Database.
- User Id. After filling in all fields, click Test to ensure the connection with the Postgre Server is working correctly.
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:
- QuerySelect
- QueryInsert
- QueryDelete
- QueryUpdate
- In Unified Namespace > Tags we created some tags for this example, they are:
- Integer01, Integer02 and Integer03: These will send the values to the Postgre DB.
- TriggerUpdate, TriggerSelect, TriggerInsert and TriggerDelete: These are used to trigger some task scripts created for the example.
- QuerySelect: This one is used to receive the result of the Select query.
- In Historian > Historian Tags configured the Integer01, Integer02, and Integer03 Tags to Table1,which is standard and is configured to use PostgreSQL.
- In Scripts > Tasks we created some tasks to Select, Delete, Update, Insert, and configured the Trigger column with marks created before. The scripts are as follows:
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 can run the project and give some different values to the Tags, thus, within pgAdmin 4 we can see that Table 1 was created with values that were given.
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 | ||||
---|---|---|---|---|
|