runNamedQuery()

I am trying to run "runNamedQuery()" from a script. I want to use it like I would the following:
data = system.db.runQuery(SELECT * FROM datatable)
Then I would use data[0][1] or something similar throughout my script.
When I try using
data = system.db.runNamedQuery(queryName, params)
I never have any data in the data dataset.

  1. Does your named query return data in the Named Query Testing tab? (You didn't say.)
  2. Does your named query return data when run from the Script Console?
  3. Your statement,
    data = system.db.runQuery(SELECT * FROM datatable)
    should be quoted thus:
    data = system.db.runQuery("SELECT * FROM datatable")
    but named queries are to be preferred.

Tip: use the </> code formatting button to preserve code indentation and apply syntax highlighting.

The named query does work in the testing tab.

The named query does not return data from the script console

Then please show how you are setting up the params variable.

When you run the following script:

Create a python dictionary of parameters to pass

params = { "param1" : "my string" , "param2" : 10 }

Run the Named Query

system.db.runNamedQuery( "myUpdateQuery" , params)

Or when you run this script:

Request the Named Query with an empty dictionary as the second parameter.

system.db.runNamedQuery( "folderName/myNamedQuery" , {})

How do you get the results of the query?

Please edit your post and format your code blocks with the </> button.

I figured out how to pull the data out of the runNamedQuery script. i.e. how to get the results from running the query.