Versions Compared

Key

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

Overview

You can use PostgreSQL database using the Tag Historian feature. The steps to achieve this involve:

  • 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
maxLevel3


Configuration PostgreSQL Via Tag Historian

Follow the steps below to configure PostgreSQL using Tag Historian.

  1. Access Datasets > DBs.
  2. Rename the SQLite database TagHistorian to TagHistorian2 or any other name. You should rename it because the system will use the TagHistorian name to configure the Postgre SQL.
  3. In DBs, click the plus icon to create a new Database Connection.
  4. In the Name field, enter TagHistorian.
  5. Choose PostgreSQL Data Provider as the Provider for the database.
  6. Click OK.
  7. In the data grid, click the Connection String column of the newly created row.
  8. Configure the connection. For the Server field, enter the IP of the Postgre Server. In addition, you need to provide the Port, Database name, and User Id. After filling in all fields, click Test to ensure the connection with the Postgre Server is working correctly.




Configuration Example

[WE NEED MORE INFORMATION ABOUT THIS EXAMPLE. IT LACKS INFORMATION TO CONNECT EVERYTHING]

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. Below you find a list of modules used and the necessary configurations.

In Datasets > Queries

some queries were created, they are:

you need to create the queries below. Access Datasets Queries to learn how to configure queries.

  • QuerySelect
  • QueryInsert
  • QueryDelete
  • QueryUpdate

In Unified Namespace > Tags we created some

tags for this example, they are

Tags to save values in the DB. To learn how to create and configure Tags access Unified Namespace. The created tags are described below:

  • Integer01, Integer02, and Integer03
: These will send the
  • are used to send values to the
Postgre
  • PostgreSQL DB.
  • TriggerUpdate, TriggerSelect, TriggerInsert, and TriggerDelete
:  These
  • are used to trigger
some task scripts
  • script tasks created for the example.
  • QuerySelect
: This one
  • is used to receive the result of the Select query.

In Historian > Historian Tags

configured

configure the Integer01, Integer02, and Integer03 Tags to Table1. Remember that to configure the PostgreSQL is connected to Tag Historian,which is standard

and is configured to use PostgreSQL

.

In addition to the above configuration, you need to accessScripts > Tasks

 we

and create we created some tasks to Select, Delete, Update, Insert, and configured the Trigger column with marks created before.

The scripts are as follows

Below you find all required scripts:

  • 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 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.

Image Removed

created. Thus, if you access the PostgreSQL Server, you can access Table1 which was created. You can also check that all values you provided are within Table1 due to the execution of previously created queries.

Image AddedThus, we trigger tasks through Trigger Tags, all Queries were successfully performed and our Table within Postgre is updated with the Queries we created before.Image Removed



In this section...

Page Tree
root@parent
spacesV10