# Force system.tag.queryTagHistory() to use specific historian db

**URL:** <https://forum.inductiveautomation.com/t/force-system-tag-querytaghistory-to-use-specific-historian-db/97774>\
**Category:** Ignition\
**Created:** [October 25, 2024, 2:21pm UTC](https://forum.inductiveautomation.com/t/force-system-tag-querytaghistory-to-use-specific-historian-db/97774 "2024-10-25T14:21:00Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [October 25, 2024, 6:46pm UTC](https://forum.inductiveautomation.com/t/force-system-tag-querytaghistory-to-use-specific-historian-db/97774/4 "2024-10-25T18:46:46Z")

</div>

When you set up a Database as a Historical Provider it becomes available to the designer, as a selection in the history section of the tag editor (as you know).

If you want to look up history for a tag path on a different provider than what is set in the tag editor, then you will need to manually construct the Historical tag path with the correct Historical Provider.

Here is a little script I adapted that shows how to do it (aside from manual concatenation).

```python
def getHistoricalTagPath(path):
    from com.inductiveautomation.ignition.common import QualifiedPath, WellKnownPathTypes,QualifiedPathUtils
    from com.inductiveautomation.ignition.common.tags.paths.parser import TagPathParser

    qPath = QualifiedPathUtils.fromTagPathNew(TagPathParser.parseSafe('default',path))
    gateway = system.tag.readBlocking('[System]Gateway/SystemName'])
    driver = ':'.join([gateway.value,qPath.getPathComponent('prov')])
    return QualifiedPath.Builder().set(WellKnownPathTypes.HistoryProvider,'YourHistoryProvider').setDriver(driver).setTag(qPath.getPathComponent('tag')).build().toString()

```

You can find the original script and conversation here:

> [@Get the Historical Tag Path from the Tag Path](https://forum.inductiveautomation.com/t/get-the-historical-tag-path-from-the-tag-path/61981/6):
>
> So, the driver is actually part of the full tag path. It is possible if you are using remote tag providers to use a gateway message handler in conjunction with this function to get what you’re looking for. If you put this function in a shared script on the same gateway as the tag provider, then it should return your historical tag path. Inspired heavily from the script provided by @PGriffith def getHistoricalTagPath(path): from com.inductiveautomation.ignition.common import QualifiedPath,…

---

_[View the full topic](https://forum.inductiveautomation.com/t/force-system-tag-querytaghistory-to-use-specific-historian-db/97774)._
