Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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
maxLevel3


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.

  1. Access Datasets > DBs.
  2. Rename the SQLite database TagHistorian to TagHistorian2 or another name.
?Image Removed
  1. Now
you can access 'Datasets > DBs', select the PostgreSQL Data Provider option and click on 'New item...' and create the Postgre with the name TagHistorian.
  1. , click the plus icon to create a new Database Connection.
  2. Enter the name TagHistorian.
  3. Choose PostgreSQL Data Provider as the provider for this database.
  4. Click OK.
    Image Added
  5. In the data grid click the Connection String column of the newly created row.
  6. Configure

Image Removed

In the ConnectionString column, you can configure
  1. the Server parameter with the IP of the Postgre Server, the Port, and the name of the Database
configured on the Postgre server
  1. .

Don't forget to configure the LogonName and LogonPassword column.

Note

Note: to modify the password column, you need to switch to Administrator.

Image Removed
  1. Image Added
Info

Click Test and

check

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
as shown in the image below. We use Select, Insert, Delete, and Update in this example.

Image Removed

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.
The "
    • TriggerUpdate
"
    • ,
"
    • TriggerSelect
"
    • ,
"
    • TriggerInsert
"
    • and
"
    • TriggerDelete
"
    • :  These are used to trigger some task scripts
that we will create in the next steps
    • created for the example.
The tag "QuerySelect"
    • QuerySelect: This one is used to receive the result of the Select query.
Image Removed
  • In
'
  • Historian > Historian Tags
', it is necessary to configure
  • configured the Integer01, Integer02, and Integer03
Tag
  • Tags to Table1,
Table1
  • which is standard and is configured to use PostgreSQL.

Image Removed

Now, in '
  • In Scripts > Tasks
' you can create
  •  we created some tasks to Select, Delete, Update, Insert, and
configure
  • configured the Trigger column with marks created before.

Image Removed

  • The scripts are as follows:
    • Select Query

      Code Block
      languagec#
      @Tag.QuerySelect = @Dataset.Quey.QuerySelect.SelectCommand();
      @Info.Trace("Select OK:
    • " + @Tag.QuerySelect);


    • Insert Query

      Code Block
      languagec#
      int i = @Dataset.Query.QueryInsert.ExecuteCommand();
      @Info.Trace("Insert OK:" + i);


    • Update Query

      Code Block
      languagec#
      int i = @Dataset.Query.QueryUpdate.ExecuteCommand();
      @Info.Trace("Update OK:" + i);


    • Delete query:

      Code Block
      languagec#
      int i = @Dataset.Query.QueryDelete.ExecuteCommand();
      @Info.Trace("Delete OK:" + i);


Now, we

Image Removed

Insert query:
Image Removed

Update Query:

Image Removed

Delete query:

Image Removed

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 .

Image Removed

Our and our Table within Postgre is updated with the Queries we created before.



In this section...

Page Tree
root@parent
spacesV10