SQL Plugin
The SQL input plugin allows continually polling an SQL server database. The plugin is able to remember its last position based on an increasing numeric column. This plugin supports Microsoft SQL server, Oracle SQL Server, and also SAP Hana Server.
Configuration location:
These configs are only used for the Edge instance Luna.Console, executed directly from the [Edge Main Folder]. Click the "Service Application" tab above to check the location for Edge services.
Use the default DataMappings.xml for most use cases.
SqlSettings.xml
The SqlSettings.xml defines where to find the SQL Server database file and how to open it.
Example configuration
Description
Provider (line 6)
Defines the type of database you want to connect to. Choose between either MsSql (Microsoft SQL Server), Oracle (Oracle SQL Server), or Hana (SAP HANA). (Note: The setting is case sensitive)
ServerAddress (line 7)
Defines where to find the database server
ConnectionTimeoutS (line 8)
Connection timeout in seconds. Defaults to 30 seconds.
Database (line 9)
Which database to open
Security (line 10)
Whether to use windows user credentials to log in to the server. If set to true, this bypasses the UserId and Password settings
Password (line 12)
Password for authenticating the edge software
UserId (line 13)
Username for authenticating the edge software
WorkstationId (line 14)
Id to identify the edge (free to set for most cases)
ConnectionString (line 15)
Adding the setting "ConnectionString" to the SqlServer configuration allows to directly enter a connection string used for connection establishment.
Note: If this setting is used, all other settings are ignored.
DataDefinition.xml
The DataDefinition.xml defines which table and which columns to read.
Example configuration
The following exemplary configuration polls the table CounterTest (line 6) every second (line 10) and reads the columns Id, Timestamp, and Counter (lines 13 to 27). A file called PersistId.json (line 47) is used to remember, which line with which Id was last read (line 16).
Make sure that the column marked with IsLastReadId = true (line 16) is implemented as an incrementing number in the SQL database table.
Settings
Setting
Description
Name (line 6)
Name of table to read
OrderBy (line 7)
Which column to order the table by. Use the column marked as IsLastReadId for most use cases
OrderDir (line 8)
Use ASC in all cases
NumberToRead (line 9)
Maximum number of rows to read in a single reading operation
PollingTimeS (line 10)
Polling interval in seconds
OnlySendChanges (line 11)
Defines, whether only changes in columns should be transmitted. For most SQL use cases, false is appropriate
Name (line 14)
Defines the name of which column to read
FilterOnly (line 15)
Flag indicating whether this column is used only for filtering
IsLastReadId (line 16)
If set to true, this column is used to remember, which row was the last read. Make sure that this column is used in the OrderBy setting (line 7) and it is implemented as incrementing number or incrementing timestamp in the SQL table to read.
IsTimestamp (line 20)
If set to true, this column is handled as an internal timestamp datapoint. Must be UNIX timestamp in milliseconds. It is highly recommended to have one column marked as a timestamp.
Filter (line 28)
The filter block allows defining 'where' clauses in the SQLITE select statement.
One or more Filter-blocks may be defined in a wrapping Filters-block (see line 34ff.)
Condition (line 29)
Whether to connect this filter logically AND or OR with other filters. Not relevant, if only one filter is defined.
Allowed values: OR, AND
Operator (line 30)
Allowed values: Greater, Less, GreaterOrEqual, LessOrEqual, Equal or NotEqual
FilterName (line 31)
Value to compare the column. In the example, only rows where column Counter equals 1 are read
MandatoryCondition
Optional. Filter marked with MandatoryCondition = true must evaluate to true, otherwise, the reading process is halted until the filter evaluates to true. If the condition in a row is not met, all the entries are read until the row which does not meet the condition.
MandatoryConditionSkipTimeMs
Optional: If a filter with MandatoryCondition = true is set for longer than MandatoryConditionSkipTimeMs (in milliseconds), the mandatory condition is skipped and the halting line is read anyhow. Note: The column definitions must contain a column with flag IsTimestamp =true
MathOperation
Optional. One or more MathOperation-blocks may be defined in a wrapping MathOperations-block (see line 48ff.).
Operation (line 52)
Defines the mathematical operation to perform.
Allowed values: Add, Subtract, Multiply, Divide, Power
If several operations are defined, the operations are applied consecutively, starting with the top-most defined operation.
Value (line 54)
Right-hand-side value of the mathematical operation. In the example, the read value of column Counter is multiplied by 1000
Last updated