IA Scripting: Error adding SQLTags to configuration store

I ran into a problem where the tag exists (or not) in my SQLTag structure but the tag.exists is not (or is) seeing the tag. Is there a chance the internal database got corrupted before the SQLTag was completely created?

When I first ran this code (see below), an SQL Query timed out on me while I was trying to monitor the database tables. The tags were not created yet, but I was still getting the same error. I imported the tags in from a test project but it is still generating the same error.

The console is generating the following error:

Gateway Timer script:

...
	#AlarmState tag
	sTag =  "AlarmState"
	sTagPath = sParentPath + "/" + sTag
	if not system.tag.exists(sTagPath):
		system.tag.addTag(parentPath=sParentPath, name=sTag, tagType="DB", dataType="Boolean")
		system.tag.write(sTagPath, 0)
...

Ignition Platform 7.5.11 (b1526)
SQL Bridge Module 5.5.5 (b289) Activated
Vision Module 6.5.11 (b928) Activated
IA Labs Scripting Module 1.5.0 (b8) Free
Mobile Module 1.5.6 (b239) Trial
ActiveX Module 2.5.0 (b198) Free
Symbol Factory Module 2.6.0 (b46) Trial
Reporting Module 1.5.3 (b229) Activated

With Greg Simpson’s help, we narrowed this down to the fact that we needed to prefix the tag path and folder name with the specific SQLTag provider when checking to see if the tag exists and also when creating the new tags with addTag:

...
   sParentPath = "[MySQLTagProvider]" + sParentPath

   #AlarmState tag
   sTag =  "AlarmState"
   sTagPath = sParentPath + "/" + sTag
   if not system.tag.exists(sTagPath):
      system.tag.addTag(parentPath=sParentPath, name=sTag, tagType="DB", dataType="Boolean")
      system.tag.write(sTagPath, 0)
...

Thanks, Greg!