You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

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:


Configuration PostgreSQL via Tag Historian

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.
  3. Now, click the plus icon to create a new Database Connection.
  4. Enter the name TagHistorian.
  5. Choose PostgreSQL Data Provider as the provider for this database.
  6. Click OK.
  7. In the data grid click the Connection String column of the newly created row.
  8. Configure the Server parameter with the IP of the Postgre Server, the Port, and the name of the Database.

Click Test and 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

      @Tag.QuerySelect = @Dataset.Quey.QuerySelect.SelectCommand();
      @Info.Trace("Select OK:" + @Tag.QuerySelect);
    • Insert Query

      int i = @Dataset.Query.QueryInsert.ExecuteCommand();
      @Info.Trace("Insert OK:" + i);
    • Update Query

      int i = @Dataset.Query.QueryUpdate.ExecuteCommand();
      @Info.Trace("Update OK:" + i);
    • Delete query:

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

The root page @parent could not be found in space v10.

  • No labels