# system.db.execQuery does not work but system.db.runNamedQuery does

**URL:** <https://forum.inductiveautomation.com/t/system-db-execquery-does-not-work-but-system-db-runnamedquery-does/117402>\
**Category:** Ignition\
**Tags:** namedqueries, perspective, scripting\
**Created:** [October 8, 2026, 8:26pm UTC](https://forum.inductiveautomation.com/t/system-db-execquery-does-not-work-but-system-db-runnamedquery-does/117402 "2026-10-08T20:26:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tuckercc](https://avatars.discourse-cdn.com/v4/letter/t/d07c76/32.png) [@tuckercc](https://forum.inductiveautomation.com/u/tuckercc)\
**Post date:** [October 8, 2026, 8:26pm UTC](https://forum.inductiveautomation.com/t/system-db-execquery-does-not-work-but-system-db-runnamedquery-does/117402/1 "2026-10-08T20:26:31Z")

</div>

I have a gateway tag change script that works. However, when I attempted to change from the system.db.runNamedQuery function to the system.db.execQuery function, it fails with the following error:

Jython Exception occurred: Traceback (most recent call last):  
File "TagChangeScript:pcsMaster/ImportFiles", line 22, in onTagChange  
TypeError: str indices must be integers

Here is the script with the new functions commented out.

```python
def onTagChange(initialChange, newValue, previousValue, event, executionCount):
    # Import Files Script
    # Import the Java Exception class
    import java.lang.Exception
    from java.lang import Throwable
    # Import traceback module
    import traceback
    # Do nothing if tag is initializing/ or gateway is starting. We may change this later.
    if initialChange:
        return
    # Only continue if data quality is good.
    if not newValue.quality:
        return
    if previousValue.value == 0 and newValue.value == 1:
        try:
            logger = system.util.getLogger("Import Files Script")
            # This is where all named queries that need to be ran will be called from.
            # Tag scripts run in Gateway scope, so the project name is required
            # CircNewTankTbl
            projectName = "pcsMaster"
            queryPath = "Cfg/qCircNewTankTbl"
            # myTankTbl = system.db.execQuery(queryPath, projectName)
            myTankTbl = system.db.runNamedQuery(projectName, queryPath)
            tagPath = "[default]Circ/CircNewTankTbl"
            system.tag.writeBlocking(tagPath, myTankTbl)
            # ManualDeviceTbl
            projectName = "pcsMaster"
            queryPath = "Cfg/qManualDeviceTbl"
            # myManualDeviceTbl = system.db.execQuery(queryPath, projectName)
            myManualDeviceTbl = system.db.runNamedQuery(projectName, queryPath)
            tagPath = "[~]Sys/ManualDeviceTbl"
            system.tag.writeBlocking(tagPath, myManualDeviceTbl)
            # Reset ImportFiles tag after all named queries have been ran.
            logger.info("Import files queries completed successfully.")
        except Exception, err:
            # push the error text to the logger
            logger.error("Jython Exception occurred: %s" % traceback.format_exc())
        except Throwable, j_err:
            # push the error text to the logger
            logger.error("Java Exception occurred: %s" % j_err.getMessage())
        else:
            # logger.info("No error.")
            pass
        finally:
            # logger.info("This always completes.")
            # Reset ImportFiles tag to FALSE
            system.tag.writeBlocking("[default]Sys/ImportFiles", 0)
            # Logs can be viewed in the gateway http://localhost:8088/app/diagnostics/logs    

```

Any help would be appreciated. I am new to Ignition, Jython, Python, so please be gentle.

---

<div class="post-metadata">

**Author:** ![Lynn\_Martineau](https://avatars.discourse-cdn.com/v4/letter/l/f1d935/32.png) [@Lynn\_Martineau](https://forum.inductiveautomation.com/u/Lynn_Martineau)\
**Post date:** [October 8, 2026, 9:24pm UTC](https://forum.inductiveautomation.com/t/system-db-execquery-does-not-work-but-system-db-runnamedquery-does/117402/2 "2026-10-08T21:24:56Z")

</div>

`system.db.execQuery` doesn't have a `projectName` argument.

It's trying to interpret the `projectName` string as a parameters dictionary.  
Try using `system.db.execQuery(queryPath,parameters={},project=projectName)`

[system.db.execQuery | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.3/appendix/scripting-functions/system-db/system-db-execQuery)

---

<div class="post-metadata">

**Author:** ![tuckercc](https://avatars.discourse-cdn.com/v4/letter/t/d07c76/32.png) [@tuckercc](https://forum.inductiveautomation.com/u/tuckercc)\
**Post date:** [October 8, 2026, 9:38pm UTC](https://forum.inductiveautomation.com/t/system-db-execquery-does-not-work-but-system-db-runnamedquery-does/117402/3 "2026-10-08T21:38:33Z")

</div>

That works. Thank you so much 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:** [October 8, 2026, 10:19pm UTC](https://forum.inductiveautomation.com/t/system-db-execquery-does-not-work-but-system-db-runnamedquery-does/117402/4 "2026-10-08T22:19:19Z")

</div>

If you're using an LLM for assistance (I'm pretty confident you are), consider...not. The script you've got is full of antipatterns and inefficiencies that are making it actively harder to maintain, and if you're new to this, learning bad habits is a bad place to start.
