DALResults¶
-
class
pyvo.dal.query.
DALResults
(votable, url=None, protocol=None, version=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: votable : str
the service response parsed into an astropy.io.votable.tree.VOTableFile instance.
url : str
the URL that produced the response
protocol : str
the name of the protocol that this response (supposedly) complies with
version : str
the version of the protocol that this response (supposedly) complies with
Raises: DALFormatError
if the response VOTable does not contain a response table
See also
Attributes Summary
nrecs
the number of records returned in this result (read-only) protocol
The service protocol which generated this query response (read-only). queryurl
the URL query that produced these results. None is returned if unknown table
the astropy table object version
The version of the service protocol which generated this query response (read-only). Methods Summary
cursor
()return a cursor that is compliant with the Python Database API’s fielddesc
()return the full metadata for a column as Field instance, a simple fieldname_with_ucd
(ucd)return the field name that has a given UCD value or None if the UCD fieldname_with_utype
(utype)return the field name that has a given UType value or None if the UType fieldnames
()return the names of the columns. These are the names that are used getcolumn
(name)return a numpy array containing the values for the column with the getdesc
(name)return the field description for the record attribute (column) with getrecord
(index)return a representation of a result record that follows dictionary getvalue
(name, index)return the value of a record attribute–a value from a column and row. Attributes Documentation
-
nrecs
¶ the number of records returned in this result (read-only)
-
protocol
¶ The service protocol which generated this query response (read-only).
-
queryurl
¶ the URL query that produced these results. None is returned if unknown
-
table
¶ the astropy table object
-
version
¶ The version of the service protocol which generated this query response (read-only).
Methods Documentation
-
cursor
()[source]¶ return a cursor that is compliant with the Python Database API’s
Cursor
interface. See PEP 249 for details.
-
fielddesc
()[source]¶ return the full metadata for a column as Field instance, a simple object with attributes corresponding the the VOTable FIELD attributes, namely: name, id, type, ucd, utype, arraysize, description
-
fieldname_with_ucd
(ucd)[source]¶ return the field name that has a given UCD value or None if the UCD is not found. None is also returned if the UCD is None or an empty stirng
-
fieldname_with_utype
(utype)[source]¶ return the field name that has a given UType value or None if the UType is not found. None is also returned if UType is None or an empty stirng
-
fieldnames
()[source]¶ return the names of the columns. These are the names that are used to access values from the dictionaries returned by getrecord(). They correspond the ID of the column, if it is set, or otherwise to the column name.
-
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: name : str
the name of the attribute (column), chosen from those in fieldnames()
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() function: either the column IDs or name, if the ID is not set. The returned record may have additional accessor methods for getting at stardard DAL response metadata (e.g. ra, dec).
Parameters: index : int
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
-
getvalue
(name, index)[source]¶ return the value of a record attribute–a value from a column and row.
Parameters: name : str
the name of the attribute (column)
index : int
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
-