How-To Guides
Integration Guides

Microsoft SQL Server Integration Guide

12min

Review the following guide for setting up an integration between Litmus Edge and a Microsoft SQL database.

Video



User Scenario

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:

Step 1: Add Device



Step 2: Add Tags



Step 3: Add Microsoft SQL Server Application

Note: The version used in this guide for Microsoft SQL Server is 2017-latest.

To add the Microsoft SQL Server Marketplace Application:

  1. In Litmus Edge, navigate to Applications > Marketplace.
  2. Click Marketplace List and select Default Marketplace Catalog.
  3. Click the Microsoft SQL Server application tile.
  4. From the Installation script version drop-down list, select 2017-CU8-ubuntu.
  5. Enter MSSQL in the Name field.
  6. Copy the password from the SA Password field or create a new one and save it for use later.
  7. Click Launch.
  8. 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.
  9. Navigate to Applications > Containers. The MSSQL application Container is running.
  10. Copy the IP address for the MSSQL application.

Step 4: Add the Microsoft SQL Server Connector

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.

Step 5: Enable the Connector

After adding the connector, click the toggle in the connector tile to enable it.

Document image


If you see a Failed status, you can review the Connector Logs and relevant error messages.

Step 6: Create Topics for Connector

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.

Step 7: Enable Topics

To enable the topics, return to the Topics tab and click the Enable all topics icon.

Enable all topics icon
Enable all topics icon


Step 8: Create Flow

You can now create a flow in Litmus Edge to verify the connection.

To create the flow:

  1. In Litmus Edge, navigate to Flows Manager.
  2. Click the Go To Flow Definition icon for a selected Flows Manager. The Flow canvas opens in a new browser tab.

    Go To Flow Definition icon
    Go To Flow Definition icon
    
  3. From the node palette, drag the DataHub Subscribe node (DataConnector section) to the canvas.

    DataHub Subscribe node
    DataHub Subscribe node
    
  4. Drag the Debug node to the canvas and connect the two nodes.
  5. Double click the DataHub Subscribe node. The Edit DataHub Subscribe Node dialog box appears.
  6. In the Topic field, paste the topic name copied in Step 6.
  7. Enter tag imported to mssql db in the Name field.
  8. If needed, configure the Datahub Subscribe connection. See the Step 3: Configure Connector Nodes section in Create a Flow to learn more.
  9. Click Done.
  10. Click Deploy.
  11. Expand the message window beneath the flow and click the Debug icon. Verify that messages are displaying.

    Debug node messages
    Debug node messages
    

Step 9: Make Make Microsoft SQL Queries

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:

  1. In Litmus Edge, navigate to Applications > Containers.
  2. Click the Terminal icon next to the MSSQL container. The MSSQL shell opens.
  3. From the MSSQL container terminal, enter /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P <sa password> , and then press ENTER.
  4. Enter select DB_NAME (), and then press ENTER.
  5. Enter go, and then press ENTER. The master database name appears.
  6. Enter select name from sys.databases, and then press ENTER.
  7. Enter go, and then press ENTER. All database names appear.
  8. Enter use master, and then press ENTER
  9. Enter go, and then press ENTER. Changed database context to master appears.
  10. Enter select * from information_schema.tables; and press ENTER.
  11. Enter go, and then press ENTER. The Table Catalog for the master database appears.
  12. Enter select * from test_table , and then press ENTER.
  13. 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.
Document image