Help Printing name of Tag?

Any tips on how to call the name of a tag?

I am attempting to write a Gateway Event Script that writes the contents of a tag to a MySQL database. I want to write the name of the tag and its value when the tag’s value exceed 90.

My script so far looks like this:

qv=system.tag.read("Power")

system.db.runPrepUpdate("INSERT INTO users (Name,Overage) VALUES (?,?);", [qv.name, qv.value], 'python')

However, when this script is run, it gives me the following error:

Traceback (most recent call last):
  File "<event:actionPerformed>", line 6, in <module>
AttributeError: 'com.inductiveautomation.ignition.common.sqltags.Ba' object has no attribute 'name'

Ignition v7.9.1 (b2017012511)
Java: Oracle Corporation 1.8.0_111

Writing to MySQL with qv.value works without a problem.

Thanks!

You will need to do a second read for the tag name.

qvName = system.tag.read(“Power.name”)

You can specify any of the Tag Attributes this way.

https://docs.inductiveautomation.com/display/DOC79/Tag+Attributes

2 Likes

Thank you so much for your help!
Made my day a lot easier.

Thanks again!