Need assistance on scripting

Hi,
I need assistance regarding scripting.

I have a named query which fetches records and I want that particular column to be stored in list.

What I have done was …
Not helping mate,
Instead of showing the data, it showing someothere inbuilt functions data

ds = system.db.runNamedQuery("Defects/Lookups/SelectHostandIP")
pds = system.dataset.toPyDataSet(ds)
LocalHostName = system.net.getHostName()
print("Printing Available HostName List")  
for HostName in pds:
    lists = HostName[0]
    print(lists)

I’m getting the result like this,
AAAA
BBBB
CCCC
DDDD

THE DESIRED output,
[AAAA,BBBB,CCCC,DDDD]

Try this:

results = system.db.runNamedQuery(...)
colList = results.getColumnAsList(columnNumber)

FYI, you can always use something like the following to get a list of available methods/attributes on an object

for item in dir(results):
	print item

Can you show the actual script you’re running? When you post, use the </> button to format it properly.

1 Like

Please take a look at the post it self.

Each print makes a new line. Instead of printing inside the loop, add the value to a list that you initialize before the loop. Then print it after the loop ends.

You don’t need to convert to pyDataSet if you use .getColumnAsList(columnNumber) directly on the named queries results

1 Like

Thanks,
Now i learned How to use this