How-To Guides
Integration Guides
Work with Tables in SQL Connectors (Create Table and Show Mapping)
10min
when you set up and configure a connection with the following sql connectors, you have the option of selecting how the data will be transferred to database tables db mysql docid\ s7rjuvidy2bp975d62 rl db mysql ssl docid\ vrqlopxh7p5mk3oko7xe2 db postgresql docid\ dv9b5yqr0bgaivxdoabxc db postgresql ssl docid\ uqk 5kpetv9rwmnf0hjll db mongodb docid 1ifgw7bbvgiq tmso44bp db mongo v4+ docid\ fr2fm04q3ebrjuoshmaud when configuring the connector, make sure to select only one of the following options option 1 create table if you select the create table check box, a default table in json will be created if one doesn't already exist the table will be used to store data sent through the connector if you select this check box, make sure to unselect the show mapping check box mysql default table if you set up a connection with db mysql docid\ s7rjuvidy2bp975d62 rl or db mysql ssl docid\ vrqlopxh7p5mk3oko7xe2 and select create table , an existing table will be used or a new one will be created using the following commands create table if not exists `table name` ( id bigint auto increment not null, record uuid char(36) not null, arrived at datetime not null, device id varchar(64) null, register id varchar(64) null, tag name varchar(64) null, datatype varchar(32) null, value text null, success tinyint null, primary key (id) ); postgresql default table if you set up a connection with db postgresql docid\ dv9b5yqr0bgaivxdoabxc or db postgresql ssl docid\ uqk 5kpetv9rwmnf0hjll and select create table , an existing table will be used or a new one will be created using the following commands create table if not exists "table name" ( id bigserial not null, record uuid uuid not null, arrived at timestamp with time zone not null, device id varchar(64) null, register id varchar(64) null, tag name varchar(64) null, datatype varchar(32) null, value varchar null, success boolean null, primary key (id) ); option 2 show mapping if you select the show mapping check box, you can send data to a custom table in the database that is already created this table can be configured in your preferred format and structure before you begin make sure you have sufficient knowledge of sql when configuring the mapping for the custom table any errors in the format will cause failures in sending data to the database the database table that will store the data from this connection will be need to be created before completing these steps this task only maps the data that will be sent to the pre existing table configure custom table mapping to configure custom table mapping, begin by following step 1, step 2, and step 3 for one of the following integration guides mysql integration guide docid\ ylf2fvlc20jazepvms99w postgresql integration guide docid\ tajxcac1qphuku0bpui1 these use cases use devicehub data from devices and tags to create the data that will be sent to the database alternatively, you can also use analytics docid\ dxce9032oqiligimolvlm or the flows manager docid\ q4jyt 6f9weaqu53lw3b to create this data when you get to step 4 to add the connector in manufacturing connect edge, configure the following parameters for the custom table table this is the name of the pre existing custom table that will store the transferred data show mapping select this check box see the configure key/value pairs section below to learn how to format key/value pairs create table make sure to unselect this check box configure key/value pairs once you select the show mapping check box, you'll be able to map the key/value pairs for the custom table to configure key/value pairs from the add a connector or edit connector dialog box, select the show mapping check box make sure the create table check box is not selected the key/value section appears in the key field, enter the name of the first column in the table in the value field, enter the value name that will be stored in the first column in the following format {{ value name}} replace value name with the corresponding key value of the json see the example below click +add the key/value pair is added to the mapping for the connector continue adding columns and corresponding values for your table mapping example you have the following data in json format {“devicename” “plc1”, “timestamp” 1239423823, "value" 123}, {“devicename” “plc1”, “timestamp” 1247382948, "value" 545}, {“devicename” “plc1”, “timestamp” 1294859324, "value" 787} you have created the following database table device name timestamp data value the show mapping section would be formatted as shown below the database table would be updated with the data as shown below device name timestamp data value plc1 1239423823 123 plc1 1247382948 545 plc1 1294859324 787