Microsoft SQL Server Integration Guide
Review the following guide for setting up an integration between Litmus Edge and a Microsoft SQL database.
In this guide you will deploy a Microsoft SQL Server database container from Litmus Edge and then integrate with the database using the DB-Microsoft SQL Server connector. For your specific scenario you may use an external Microsoft SQL Server database to set up the integration.
For external Microsoft SQL Servers, refer to the following to learn more:
Note: The version used in this guide for Microsoft SQL Server is 2017-latest.
To add the Microsoft SQL Server Marketplace Application:
- In Litmus Edge, navigate to Applications > Marketplace.
- Click Marketplace List and select Default Marketplace Catalog.
- Click the Microsoft SQL Server application tile.
- From the Installation script version drop-down list, select 2017-CU8-ubuntu.
- Enter MSSQL in the Name field.
- Copy the password from the SA Password field or create a new one and save it for use later.
- Click Launch.
- Navigate to Applications > Catalog Apps. The Microsoft SQL Server application appears, pulls the image, and then starts the application. The MSSQL application shows as running.
- Navigate to Applications > Containers. The MSSQL application Container is running.
- Copy the IP address for the MSSQL application.
Follow the steps to Add a Connector and select the DB - Microsoft SQL Server provider.
Configure the following parameters.
- Name: Enter a name for the connector.
- Hostname: Paste the IP address you copied in Step 3.
- Port: The MSSQL Server port. The default value is 1433.
- Username: Enter sa.
- Password (Optional): Enter the user password you copied in Step 3.
- Database: Enter master.
- Table: Enter test_table. If you are sending data to an existing table, use the corresponding name.
- Show Mapping: If you want to send data to a custom table, select this check box and unselect Create table. See Work with Tables in SQL Connectors (Create Table and Show Mapping) to learn more. To add key/value pairs for the custom table, see Configure Key/Value Pairs.
- Create table: If you want to send data to an existing table in the default format, or you want to create a new table in the default format, select this check box and unselect Show Mapping. See Work with Tables in SQL Connectors (Create Table and Show Mapping) to learn more.
- Commit timeout: Enter the transaction commit timeout in (ms).
- Max transaction size: Enter the maximum number of messages before a transaction is committed, regardless of timeout parameter.
- Bulk insert count: To enable this option, enter the number of messages to group together and send as one bulk insert statement. Enabling this option can improve how quickly data is processed when dealing with high volumes of tags.
- Throttling limit: The maximum number of messages per second to be processed. The default value is zero, which means that there is no limit.
- Persistent storage: When enabled, this will cause messages to undergo a store-and-forward procedure. Messages will be stored within Litmus Edge when cloud providers are online.
- Queue Mode: Select the queue mode as lifo (last in first out) or fifo (first in first out). Selecting lifo means that the last data entry is processed first, and selecting fifo means the first data entry is processed first.
After adding the connector, click the toggle in the connector tile to enable it.
If you see a Failed status, you can review the Connector Logs and relevant error messages.
You will now need to import the tags created in Step 2 as topics for the Microsoft connector. The topics will be created as outbound topics.
After adding all required topics, navigate to the Integration overview page and ensure the connector is not disabled and still shows a CONNECTED status.
To enable the topics, return to the Topics tab and click the Enable all topics icon.
You can now create a flow in Litmus Edge to verify the connection.
To create the flow:
- In Litmus Edge, navigate to Flows Manager.
Click the Go To Flow Definition icon for a selected Flows Manager. The Flow canvas opens in a new browser tab.
From the node palette, drag the DataHub Subscribe node (DataConnector section) to the canvas.
- Drag the Debug node to the canvas and connect the two nodes.
- Double click the DataHub Subscribe node. The Edit DataHub Subscribe Node dialog box appears.
- In the Topic field, paste the topic name copied in Step 6.
- Enter tag imported to mssql db in the Name field.
- If needed, configure the Datahub Subscribe connection. See the Step 3: Configure Connector Nodes section in Create a Flow to learn more.
- Click Done.
- Click Deploy.
Expand the message window beneath the flow and click the Debug icon. Verify that messages are displaying.
You can now verify that you can view data through the terminal command window.
Update credentials, the database name, and the table as needed for your specific configurations.
To make queries in the container terminal:
- In Litmus Edge, navigate to Applications > Containers.
- Click the Terminal icon next to the MSSQL container. The MSSQL shell opens.
- From the MSSQL container terminal, enter /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P <sa password> , and then press ENTER.
- Enter select DB_NAME (), and then press ENTER.
- Enter go, and then press ENTER. The master database name appears.
- Enter select name from sys.databases, and then press ENTER.
- Enter go, and then press ENTER. All database names appear.
- Enter use master, and then press ENTER
- Enter go, and then press ENTER. Changed database context to master appears.
- Enter select * from information_schema.tables; and press ENTER.
- Enter go, and then press ENTER. The Table Catalog for the master database appears.
- Enter select * from test_table , and then press ENTER.
- Enter go, and then press ENTER. If you selected Create table in Step 4, identification messages from the topic appear, including the deviceId and registerId at the end of each message. If you selected Show Mapping in Step 4, the custom mapping you configured appears.