DALResults

class pyvo.dal.DALResults(votable, *, url=None, session=None)[source]

Bases: object

Results from a DAL query. It provides random access to records in the response. Alternatively, it can provide results via a Cursor (compliant with the Python Database API) or an iterable.

initialize the cursor. This constructor is not typically called by directly applications; rather an instance is obtained from calling a DALQuery’s execute().

Parameters:
votablestr

the service response parsed into an astropy.io.votable.tree.VOTableFile instance.

urlstr

the URL that produced the response

sessionobject

optional session to use for network requests

Raises:
DALFormatError

if the response VOTable does not contain a response table

See also

DALFormatError

Attributes Summary

fielddescs

return the full metadata the columns as a list of Field instances, a simple object with attributes corresponding the the VOTable FIELD attributes, namely: name, id, type, ucd, utype, arraysize, description

fieldnames

return the names of the columns.

queryurl

the URL query that produced these results.

resultstable

The votable XML element astropy.io.votable.tree.TableElement

status

The query status as a 2-element tuple e.g.

table

votable

The complete votable XML Document astropy.io.votable.tree.VOTableFile

Methods Summary

broadcast_samp(*[, client_name])

Broadcast the table to client_name via SAMP

cursor()

return a cursor that is compliant with the Python Database API's Cursor interface.

fieldname_with_ucd(ucd)

return the field name that has a given UCD value or None if the UCD is not found.

fieldname_with_utype(utype)

return the field name that has a given UType value or None if the UType is not found.

from_result_url(result_url, *[, session])

Create a result object from a url.

getcolumn(name)

return a numpy array containing the values for the column with the given name

getdesc(name)

return the field description for the record attribute (column) with the given name

getrecord(index)

return a representation of a result record that follows dictionary semantics.

getvalue(name, index)

return the value of a record attribute--a value from a column and row.

to_qtable()

Returns a astropy QTable object containing quantities instead of simple values

to_table()

Returns a astropy Table object.

Attributes Documentation

fielddescs

return the full metadata the columns as a list of Field instances, a simple object with attributes corresponding the the VOTable FIELD attributes, namely: name, id, type, ucd, utype, arraysize, description

fieldnames

return the names of the columns. These are the names that are used to access values from the dictionaries returned by getrecord(). They correspond to the column name.

queryurl

the URL query that produced these results. None is returned if unknown

resultstable

The votable XML element astropy.io.votable.tree.TableElement

status

The query status as a 2-element tuple e.g. (‘OK’, ‘Everythings fine’)

table
votable

The complete votable XML Document astropy.io.votable.tree.VOTableFile

Methods Documentation

broadcast_samp(*, client_name=None)[source]

Broadcast the table to client_name via SAMP

cursor()[source]

return a cursor that is compliant with the Python Database API’s Cursor interface. See PEP 249 for details.

fieldname_with_ucd(ucd)[source]

return the field name that has a given UCD value or None if the UCD is not found.

fieldname_with_utype(utype)[source]

return the field name that has a given UType value or None if the UType is not found.

classmethod from_result_url(result_url, *, session=None)[source]

Create a result object from a url.

Uses the optional session to make the request.

getcolumn(name)[source]

return a numpy array containing the values for the column with the given name

getdesc(name)[source]

return the field description for the record attribute (column) with the given name

Parameters:
namestr

the name of the attribute (column)

Returns:
object

with attributes (name, id, datatype, unit, ucd, utype, arraysize) which describe the column

getrecord(index)[source]

return a representation of a result record that follows dictionary semantics. The keys of the dictionary are those returned by this instance’s fieldnames attribute.The returned record may have additional accessor methods for getting at stardard DAL response metadata (e.g. ra, dec).

Parameters:
indexint

the integer index of the desired record where 0 returns the first record

Returns:
Record

a dictionary-like wrapper containing the result record metadata.

Raises:
IndexError

if index is negative or equal or larger than the number of rows in the result table.

See also

Record
getvalue(name, index)[source]

return the value of a record attribute–a value from a column and row.

Parameters:
namestr

the name of the attribute (column)

indexint

the zero-based index of the record

Raises:
IndexError

if index is negative or equal or larger than the number of rows in the result table.

KeyError

if name is not a recognized column name

to_qtable()[source]

Returns a astropy QTable object containing quantities instead of simple values

Returns:
astropy.table.QTable
to_table()[source]

Returns a astropy Table object.

Returns:
astropy.table.Table