Writing data to dataset tag

I'm using ignition version 8.1.35 and writing queried data to a dataset tag using system.tag.writeBlocking() and am getting error 'ValueError: Lenght of values does not match length of paths'. I can't seem to figure out why.

I ran the same scrip on version 8.1.39 with no errors and everything worked.

You're going to have to share your script for anyone to help. (Make sure to use a code block when sharing and not a straight copy/paste or screenshot)

Also, per the error, it's saying you don't have a matching number of tags compared to values. These need to be the same count/size.

I'm not sure what you mean by code block.

Show it as preformatted text using this icon in the toolbar:
image

1 Like
db_connection = "postgres"

#grab table name via DieShot tag
tagPath1 = '[default]DieModel'
tagPath2 = '[default]DieShot'
tagPath3 = '[default]Query_Data'

schemaDesignation = system.tag.readBlocking(tagPath1)[0].value
schemaName = 'Die_Model_' + schemaDesignation
tableName = system.tag.readBlocking(tagPath2)[0].value

# Define the query
query = 'SELECT shot, ch1, ch2, ch3, ch4, total, corner FROM "{}"."{}"'.format(schemaName, tableName)

result = system.db.runPrepQuery(query, database=db_connection)

system.tag.writeBlocking(tagPath3, result)

system.tag.writeBlocking() expects two parameters, a list of tag paths, and a list of tag values. The length of the two lists must match.

Also, you should read both tags at once instead of doing two reads.

db_connection = "postgres"

readPaths = ['[default]DieModel','[default]DieShot']
writePaths = ['[default]Query_Data']

schemaValues = system.tag.readBlocking(readPaths)
schemaDesignation = schemaValues[0].value
schemaName = 'Die_Model_{}'.fomrat(schemaDesignation)
tableName = schemaValues[1].value

query =  'SELECT shot, ch1, ch2, ch3, ch4, total, corner FROM "{}"."{}"'.format(schemaName, tableName)

result = system.db.runPrepQuery(query, database=db_connection)

system.tag.writeBlocking(writePaths, [result])
1 Like

Thank you for the reply. I know my code could have been cleaner. After implementing changes line by line the issue seems to have been my lack of brackets around 'result' in system.tag.writeBlocking. Thank you for your help.