How-To Guides
Flows Guides
Write to Databases with Integration Topics
7min
you can create flows to send data to a database through integration topics before you begin make sure you follow the preferable database integration in the integration guides docid\ novkmu18kezvhswjtbnpc for this tutorial, we will use the mysql integration guide docid\ zxgqi3wazzgupoxgrul p step 1 add a device follow the steps to connect a device and configure the following parameters device type simulator driver name generator enable alias topics select the checkbox step 2 add tags after connecting the device, add tags to the device tag 1 tag1 name select s random value generator value type select float64 polling interval enter 5 tag name enter tag1 min value enter 10 max value enter 50 step 3 add a database integration topic to add a database integration topic in litmus edge, navigate to integration click a database integration tile make sure the tile has a connected status click topics click add a new subscription icon the data integration dialog box appears data direction select local to remote outbound local data topic click the search icon, and then select the device and alias topic for the tag you previously created toggle enable to enable the topic click yes note modifying topics restarts the connector step 4 create flow to create the flow navigate to the flows manager and create a new flow see create a flow docid\ veyyte7xdcangglzbqya0 to learn more drag the inject , function , and datahub publish nodes to the canvas and wire them together drag the datahub subscribe and debug nodes to the canvas and wire them together double click the function node in the on message tab, input the code below, ensuring to update the variables obj name , obj num , and msg subjectinput to match your topic and database var obj = {}; // create an empty json object obj name ="test table"; // write the name of your database integration remote data topic in the quotation marks obj num = 99000; // change num to be one of the names of your columns or change 99000 to a value that you want to insert into the database msg payload = json stringify(obj); // puts the json object into the message payload msg subjectinput = "test table"; // write the name of your database integration remote data topic in the quotation marks return msg; click done double click the datahub publish node datahub configure the datahub publish connection if needed see create a flow docid\ veyyte7xdcangglzbqya0 to learn more topic enter your topic name click done double click the datahub subscribe node datahub configure the datahub subscribe connection if needed see create a flow docid\ veyyte7xdcangglzbqya0 to learn more topic enter your topic name click done click deploy expand the message window beneath the flow click the inject node button to insert rows into the database click the debug icon to view the data output step 5 verify the results in database you can query the database to confirm that the integration topic inserted the data properly see mysql integration guide docid\ zxgqi3wazzgupoxgrul p to learn more