SimpleQuery

class lsst.daf.butler.SimpleQuery

Bases: object

A struct that combines SQLAlchemy objects representing SELECT, FROM, and WHERE clauses.

Attributes Summary

from_ The FROM clause of the query (sqlalchemy.sql.FromClause).

Methods Summary

combine() Combine all terms into a single query object.
copy() Return a copy of this object, with new lists for the where and columns attributes that can be modified without changing the original.
join(table, *, onclause, isouter, full, **kwargs) Add a table or subquery join to the query, possibly adding SELECT columns or WHERE expressions at the same time.

Attributes Documentation

from_

The FROM clause of the query (sqlalchemy.sql.FromClause).

This property cannot be set. To add tables to the FROM clause, call join.

Methods Documentation

combine() → sqlalchemy.sql.selectable.Select

Combine all terms into a single query object.

Returns:
sql : sqlalchemy.sql.Select

A SQLAlchemy object representing the full query.

copy() → lsst.daf.butler.core.simpleQuery.SimpleQuery

Return a copy of this object, with new lists for the where and columns attributes that can be modified without changing the original.

Returns:
copy : SimpleQuery

A copy of self.

join(table: sqlalchemy.sql.selectable.FromClause, *, onclause: Optional[sqlalchemy.sql.elements.ColumnElement] = None, isouter: bool = False, full: bool = False, **kwargs) → None

Add a table or subquery join to the query, possibly adding SELECT columns or WHERE expressions at the same time.

Parameters:
table : sqlalchemy.sql.FromClause

Table or subquery to include.

onclause : sqlalchemy.sql.ColumnElement, optional

Expression used to join the new table or subquery to those already present. Passed directly to sqlalchemy.sql.FromClause.join, but ignored if this is the first call to SimpleQuery.join.

isouter : bool, optional

If True, make this an LEFT OUTER JOIN. Passed directly to sqlalchemy.sql.FromClause.join.

full : bool, optional

If True, make this a FULL OUTER JOIN. Passed directly to sqlalchemy.sql.FromClause.join.

**kwargs

Additional keyword arguments correspond to columns in the joined table or subquery. Values may be:

  • Select (a special tag type) to indicate that this column should be added to the SELECT clause as a query result;
  • None to do nothing (equivalent to no keyword argument);
  • Any other value to add an equality constraint to the WHERE clause that constrains this column to the given value. Note that this cannot be used to add IS NULL constraints, because the previous condition for None is checked first.