Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Home
  • Knowledge base
  • Contact Us
  • Home
  • Connectors
  • SQL

SQL - Instance & item setup

How to setup a SQL instance and item in SIA

Written by Alexandru Mircea Dima

Updated at September 21st, 2022

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Installation & Technical information
    Introduction SIA Connect Standalone SIA Connect ANY-Ware Cellular & WiFi connectivity
  • Configuration in the Web UI
    Getting started with the UI Connectors Instances Items Mapping Data System Network Tools & Add-ons DigiCert IoT Trust Manager
  • Connectors
    Siemens S7 Azure IoT Ethernet/IP Mitsubishi MELSEC OPC-UA Server SQL MQTT Omron Host Link REST API Omron FINS Keyence Beckhoff TwinCAT BACnet Virtual OPC-UA Client MS SQL File M-Bus Modbus
  • Scripting & Variables
    Data formatting
  • Developers
    API documentation Shadow API
  • Tutorials & Guides
    InfluxDB AWS IoT Core - Amazon Web Services Microsoft Power BI KaaIoT Siemens S7 AVEVA Insight SIA Connect Demo Rack Grafana Azure
  • General
+ More

Table of Contents

ParametersInstanceItemReturned values

The SQL Connector SIA is compatible with the MS SQL and MySQL databases.

There is support for Oracle database but with another Connector.


Parameters

When using the SQL Connector the instance has specific parameters. These parameters are required as they are needed to establish connection. The parameters for the item are the name and the SQL query to be passed to the database


Instance

The instance needs the following parameters to establish a connection to the database:


Parameter Description
Name (instance default) User given name for the instance
Address (instance default) The IP address of the SQL database
Username Database username
Password Database password
Database Database name
Connection String (MS SQL only)  Additional connection parameters


Item

Each item reflects a SQL query for SELECT rows from a table in a database.
An item are automatically created called "Query write" which are to be called for writing queries to the database table.

Parameter Description
Query SQL query to the database


Returned values

Example where "id" and "value" are the two columns in the table "siademo":

Name

Response Value

SQL Query

Latest row table values

{"id":"5","value":"1337"}]

SELECT TOP 1 * FROM siademo ORDER BY ID DESC

Latest value

1337

SELECT TOP 1 value FROM siademo ORDER BY ID DESC

Oldest row Table values

[{"id":"1","value":"38"}]

SELECT TOP 1 * FROM siademo

Oldest 5 rows from Table VALUES

[{"id":"1","value":"38"},{"id":"2","value":"55"},{"id":"3","value":"777"},{"id":"4","value":"7575"},{"id":"5","value":"1337"}]

SELECT TOP 10 * FROM siademo

The return of the query selecting one or more rows is a JSON formatted string where each object in the array corresponds to a row from the database table. 
The return of the query selecting one value is a string containing the value of column at the specified row.




mysql microsoft sql azure sql

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • Validating data exchange between AWS IoT Core and PLC
  • Bulking multiple data items into a JSON message

0
0
Expand