Extracting row and column data from pydataset

I am doing an SQL query which will return one row.
I need to create a pydict of key:value pairs based on the column headers and row data.

So far i have managed to use the following code from another topic) to extract column headers as a list.
But i can’t get a python list out of the row data.

pydata = system.db.runPrepQuery(query ,args ,db)
keys = list(pydata.getUnderlyingDataset().getColumnNames())
values = list(pydata.getUnderlyingDataset().getData())

The ‘values’ object is an annoying java.lang.object array type.
I could always use a loop through the dataset to extract the row values into a list, but i was just trying to avoid using a loop if possible.

pydata = system.db.runPrepQuery(query ,args ,db)
columnHeaders = system.dataset.getColumnHeaders(pydata.getUnderlyingDataset())

print dict(zip(columnHeaders, pydata[0]))
4 Likes