icat.query — Provide the Query class

class icat.query.Query(client, entity, order=None, conditions=None, includes=None, limit=None)

Bases: object

Build a query to search an ICAT server.

The query uses the JPQL inspired syntax introduced with ICAT 4.3.0. It won’t work with older ICAT servers.

setOrder(order)

Set the order to build the ORDER BY clause from.

Parameters:order (list of str or bool) – the list of the attributes used for sorting. A special value of True may be used to indicate the natural order of the entity type. Any false value means no ORDER BY clause.
Raises ValueError:
 if the order contains invalid attributes that either do not exist or contain one to many relationships.
addConditions(conditions)

Add conditions to the constraints to build the WHERE clause from.

Parameters:conditions (dict) – the conditions to restrict the search result. This must be a mapping of attribute names to conditions on that attribute. The latter may either be a string with a single condition or a list of strings to add more then one condition on a single attribute. If the query already has a condition on a given attribute, it will be turned into a list with the new condition(s) appended.
Raises ValueError:
 if any key in conditions is not valid.
addIncludes(includes)

Add related objects to build the INCLUDE clause from.

Parameters:includes (iterable of str) – list of related objects to add to the INCLUDE clause. A special value of “1” may be used to set (the equivalent of) an “INCLUDE 1” clause.
Raises ValueError:
 if any item in includes is not a related object.
setLimit(limit)

Set the limits to build the LIMIT clause from.

Parameters:limit (tuple) – a tuple (skip, count).
copy()

Return an independent clone of this query.

Previous topic

icat.listproxy — Provide the ListProxy class

Next topic

icat.sslcontext — Helper functions and classes related to SSL contexts