Skip to main content
1-Visitor
January 3, 2018
Question

Running SQL queries on Thingworx data?

  • January 3, 2018
  • 1 reply
  • 5967 views

Hi,

This is my shorter version of another similar post in which I was looking for more of the theoretical explanations but here I just want to focus on the implementation part of it.

For. eg: If I have a car which has speed, distance and tire pressure as its properties, then how can I use the MsSQL to query the different properties and a combination of these?

Thanks!

1 reply

22-Sapphire I
January 3, 2018

Thingworx doesn't directly support MS SQL, if you are using MS SQL as the persistence provider, you could write queries against the schema using a separate JDBC connection.

Else within Thingworx use QueryDataTableEntries / QueryStreamEntriesWithData etc

Here is a description of how to create the Query object

PTC

tyadav1-VisitorAuthor
1-Visitor
January 6, 2018

Hi Pai Chung,

Thanks for the reply. Yes, I am using MSsql as the persistence provider.

Is there an example available as to how to write queries using JDBC connection? I thought that the SQL querying can be done by creating a SQL (query) based service using the Relational DB Connector extension. Is it not a correct way?

It would be really helpful if you can give an example of how to run an SQL query.

Also, with the QueryDataTableEntries / QueryStreamEntriesWithData, after writing the sample queries as here (PTC)  All I am getting is the names of the properties as columns and not their values. An example to run this query would be appreciated as well.

Thanks!

22-Sapphire I
January 8, 2018

You can check the following on Streams and Datatables to see if there is any data, by going to the home mashup section in Composer of that entity. it will show data if anything is stored.

If you are storing in a value stream, you will need to use querypropertyhistory or similar from the Thing that is storing into the valuestream.

Relational DB connector is the same as making a JDBC connection, I'm just referring to what Thingworx leverages which are JDBC drivers.