Skip to main content
1-Visitor
September 9, 2019
Question

How to insert the values in infotable as a whole in to the external database tables ?

  • September 9, 2019
  • 1 reply
  • 3693 views

Hello ,

I am able to upload a CSV file into the platform and able to make those values in CSV file to store in a infotable in thingworx platform.

 

But from there I should insert the values into a table that exists in the external database like postgres .

I had gone through the community but I did'nt find any solution.

Can someone please help me out .

 

Regards,

Bhargav.

1 reply

16-Pearl
September 9, 2019
16-Pearl
September 20, 2019

@Bhargav1  

I just wanted to follow up to see if previous response was helpful for your question?

 

If so, please indicate the appropriate response as the Accepted Solution for the benefit of other Community members who have the same question. If you are still experiencing issues, please do let us know your questions or concerns.

 

Thanks,

Vibhuti

Bhargav11-VisitorAuthor
1-Visitor
September 24, 2019

var tableLength = infotables.rows.length;
for (var x=0; x < tableLength; x++) {
var row = infotables.rows[x];
//var result = row.id;
try {
var command = "INSERT INTO containerproduct (containerid,productname ) VALUES ('" +
row.id + "', '" + row.productname + "')";

logger.debug("Database_test.Insert_data_to_database(): Query - " + command);
var result = me.run_command({command: command});
} catch(error) {
logger.error("Database_test.Insert_data_to_database(): Error - " + error.message);
}
}

This the code I am using to insert the data in infotable to external database by local(javascript) service but I am unsuccessful in inserting.

I have written one more service with sql command and that service has an input as command with base type as String and code section is filled with <<command>>

 

Where the command in the above code gives input to the sql command service.

 

Regards,

Bhargav Sai Ch