SQL query for DB tags

I am using 7.2.8 on an Opensuse Linux system.
I have set up two database connections on the Gateway:
MySQL_DB (defalut) to a MySQL database and Sqlite_DB to a sqlite database
Both connections are working fine as I have successfully queried each database using the Ignition database query browser.
I am trying to create a new DB tag with its value derived from a SQL query of the non-default database connection (Sqlite_DB). Using the SQL Query part of the Expression/SQL page, I can create a query but the option of selecting the database is grayed out. Is this supposed to be this way? From reading the forum I recognize this may be a feature that has not been implemented yet and the alternative is to create an Expression. I have tried that also but it is not working correctly. (I used executeScalarQuery but I am not positive about the syntax.)


Yes, you’ve understood correctly. In “SQL Query” mode, it’s not currently possible to select a different database. We unfortunately tease you by have that grayed out box there, because it is possible when using client tags. We really should get around to making it possible soon.

In the mean time, you’re also correct that you can use an expression. You should be able to use something like:

executeScalarQuery("SELECT 1", "Sqlite_DB")

Let me know if you can’t get it to work. If the tag has an error icon, right-click and select “Tag Diagnosics” to see the error.


fixed the executeScalarQuery:

I incorrectly thought the syntax was executeScalarQuery(“query”, [Sqlite_DB]) but with executeScalarQuery(“query”, “Sqlite_DB”) it works great.

Thank you