Skip to content

Add support for 'like' comparator in the query() function of PdsClient class #44

@stevenlujpl

Description

@stevenlujpl

In order to query text fields using PDSC, we want to add support for like comparator in the query() function of PdsClient class.

pdsc/pdsc/client.py

Lines 141 to 173 in 74893bb

def query(self, instrument, conditions=None):
"""
Supports a generic query of observations based on metadata
:param instrument:
PDSC instrument name
:param conditions:
a collection of tuples indicating query constraints; each tuple
should contain three entries:
- metadata variable name
- comparator (``'='``, ``'<'``, ``'>'``, ``'<='``, ``'>='``)
- value
A SQL-like query will be performed with a logical AND of the
specified conditions
:return: a list of :py:class:`~pdsc.metata.PdsMetadata` objects
corresponding to observations matching the specified query
conditions
>>> import pdsc
>>> client = pdsc.PdsClient()
>>> metadata = client.query('hirise_rdr', [
... ('corner1_latitude', '>', -0.5),
... ('corner1_latitude', '<', 0.5)
... ])
.. Warning::
This function currently assumes non-adversarial inputs; the current
implementation allows a potential SQL injection attack.
"""

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions