Object has no atrtribute 'run'

I want to modify the .Start_Date and End Date from a Date Range with a SQL Query result

The code:
import system
import sys
OF = event.source.parent.getComponent(‘Busca_OF’).intValue
buscaIni = “SELECT FECHAINICIO FROM HISTORICOS_OF WHERE ORDEN =’%i’” %(OF),“again”
buscaFin = “SELECT FECHAFIN FROM HISTORICOS_OF WHERE ORDEN =’%i’” %(OF),“again”
Inicio = system.db.run.PrepQuery(buscaIni)
Fin = system.db.run.PrepQuery(buscaFin)

if event.button == 1:
event.source.parent.getComponent(‘Date Range’).Start_Date = Inicio
event.source.parent.getComponent(‘Date Range’).End_Date = Fin

I get:
Traceback (most recent call last):
File “event:mouseClicked”, line 6, in
AttributeError: ‘com.inductiveautomation.ignition.common.script.Scr’ object has no attribute ‘run’

Any Idea?

It’s system.db.runPrepQuery
Also if you type system. and then CTRL+ENTER you’ll get a list of all the functions available, so you don’t get typo errors like this one.

I have the function available… :frowning:

Ok, but you wrote system.db.run.PrepQuery but the function is system.db.runPrepQuery ( you wrote a dot between run and PrepQuery )

Thanks c.bertulli

This is the new code…
image

And the new error… :roll_eyes:

The args argument of the runPrepUpdate function needs to be supplied as a list, you’re supplying it as an int

https://docs.inductiveautomation.com/display/DOC80/system.db.runPrepUpdate