Overview
It is possible to establish a robust and secure connection with a PostgreSQL database using 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.
On this page:
Table of Contents | ||
---|---|---|
|
Configuration PostgreSQL via Tag Historian
In this example, we present the configuration of Postgre using TagHistorian.
First, you can access 'Datasets > DBs' and need to rename the SQLite database "TagHistorian" to "TagHistorian2"To configure Postgre using Tag Historian, follow the steps below.
- Access Datasets > DBs.
- Rename the SQLite database TagHistorian to TagHistorian2 or another name.
- Now
- , click the plus icon to create a new Database Connection.
- Enter the name TagHistorian.
- Choose PostgreSQL Data Provider as the provider for this database.
- Click OK.
- In the data grid click the Connection String column of the newly created row.
- Configure
In the ConnectionString column, you can configure
- the Server parameter with the IP of the Postgre Server, the Port, and the name of the Database
- .
Don't forget to configure the LogonName and LogonPassword column.
Note |
---|
Note: to modify the password column, you need to switch to Administrator. |
Info |
---|
Click Test and |
ensure the connection with the Postgre Server is working correctly. |
Use Example
In '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
Now, in 'Unified Namespace > Tags', it is possible to create some Tags to use in this example. The Integer01, Integer02, and Integer03 are Tags that we will use to send
- , 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.
Now, in '
- 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
Insert query:
Update Query:
Delete query:
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 .
Our and our Table within Postgre is updated with the Queries we created before.
In this section...
Page Tree | ||||
---|---|---|---|---|
|