# How to Programmatically Check if a Database Connection is Actively in Use Before Deleting It in Ignition Perspective?

**URL:** <https://forum.inductiveautomation.com/t/how-to-programmatically-check-if-a-database-connection-is-actively-in-use-before-deleting-it-in-ignition-perspective/107548>\
**Category:** Ignition\
**Tags:** scripting, perspective\
**Created:** [June 18, 2025, 7:39pm UTC](https://forum.inductiveautomation.com/t/how-to-programmatically-check-if-a-database-connection-is-actively-in-use-before-deleting-it-in-ignition-perspective/107548 "2025-06-18T19:39:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Farhan\_Basheer](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/farhan_basheer/32/66759_2.png) [@Farhan\_Basheer](https://forum.inductiveautomation.com/u/Farhan_Basheer)\
**Post date:** [June 18, 2025, 7:39pm UTC](https://forum.inductiveautomation.com/t/how-to-programmatically-check-if-a-database-connection-is-actively-in-use-before-deleting-it-in-ignition-perspective/107548/1 "2025-06-18T19:39:07Z")

</div>

Hi Community,

I’m working on a project in **Ignition Perspective (v8.1.38)** where I need to **safely delete a database connection** through a user interface.

Before allowing a user to delete a database connection (for example, `ignition_test`), I want to **programmatically check if the connection is actively in use** — meaning if other sessions, users, or running scripts are currently utilizing that connection.

Here’s what I’ve discovered so far:

- `system.db.getConnectionInfo(connectionName)` provides the connection status (`Valid` or `Faulted`), but it doesn’t provide details on **active or idle connection counts.**
- The active connection pool statistics are visible in **Gateway \> Status \> Connections \> Databases** , but I couldn’t find a scripting function to access this data.

* * *

### **What I’m trying to achieve:**

Programmatically determine if a database connection is **actively in use** (for example, via connection pool usage or ongoing queries)  
Prevent deletion if the connection is currently active or busy

* * *

### **Questions:**

1. **Is there a way to programmatically check active or idle connection counts in Ignition Perspective scripting?**
2. **Is there a built-in mechanism to safely handle connection deletion if it is currently in use?**
3. **If this is not accessible through scripting, is there any recommended best practice to handle this scenario?**

* * *

### **Context:**

- Ignition Version: 8.1.38
- Scope: Perspective
- Database Type: MSSQL (but applicable to any)

* * *

### Thanks in advance for your help!

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 18, 2025, 8:04pm UTC](https://forum.inductiveautomation.com/t/how-to-programmatically-check-if-a-database-connection-is-actively-in-use-before-deleting-it-in-ignition-perspective/107548/2 "2025-06-18T20:04:39Z")

</div>

This seems like a fundamentally misguided thing to do; most critically because just because a connection is not **currently** being used does not mean it will not **ever** be used. Ignition's highly dynamic nature makes it effectively impossible to determine whether a connection is used other than by tracking actual usage.

That said, there will be system tags available for each extant database connection which you can monitor:

> **[System Tags | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/platform/tags/types-of-tags/system-tags#database-system-tags)**
>
> System Tags provide status about the Ignition system, such as memory usage, performance metrics, and so on. System Tags cannot be deleted or modified. To view the System Tags in the Tag Browser, go to the Tag Provider Selector and select System.

---

<div class="post-metadata">

**Author:** ![Farhan\_Basheer](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/farhan_basheer/32/66759_2.png) [@Farhan\_Basheer](https://forum.inductiveautomation.com/u/Farhan_Basheer)\
**Post date:** [June 18, 2025, 8:54pm UTC](https://forum.inductiveautomation.com/t/how-to-programmatically-check-if-a-database-connection-is-actively-in-use-before-deleting-it-in-ignition-perspective/107548/3 "2025-06-18T20:54:07Z")

</div>

Thanks sir, this is useful information. But my simple test is only changing one value inside the Tag of Database which is `QueriesPerSecond` I am not sure how can I use it to detect if a connection is being used. Maybe I can do some kind of logging with time stamp and make the decision.
