SQL Connection Query

I have a bit of a technical question one of our IT folks is asking. We have a production line with its own MSSQL database. Production folks asked me to tie into a MSSQL database from a separate operation to pull daily production data. No problem, had it up and working in no time. This “secondary” connection is only to pull production data two or three times a day. The IT fella is concerned that the connection always stays open, and Ignition is querying the DB every four seconds. I’m assuming this is solely to check connectivity, correct? At any rate, I’m trying to appease him, and wanted to find out:

  1. Is there any way that I can, through scripting, connect only as required, query the data, then close the connection? This would be his favorite option.
  2. Either turn off or increase the delay on the connectivity query, so we’re not checking every four seconds or so?
  3. Any documentation I can point him to that says this isn’t a problem.


The database connection does try to stay connected at all times. If you are not running any queries we still run a validation query to the database every 4 seconds that is “SELECT 1”. That query is harmless and won’t cause any performance problems.

If they would prefer the connection is disabled and enabled only when you use it there is a module we have written called “IA Labs Scripting Module” that gives you scripting functions to enable/disable a database connection. You can download the module here:


There is a function called system.db.setDatasourceEnabled that you can use.

Thanks, Travis. I didn’t even think to look at the Scripting module. I don’t know why he’s fixated on the 4-second query impacting performance. This particular DB is only updated once a minute or so, with one record being added. Either way, I’ll pass this info along. Thanks.