SimpleQuery

class lsst.daf.butler.SimpleQuery

Bases: object

A struct that combines SQLAlchemy objects.

Represents SELECT, FROM, and WHERE clauses.

Attributes Summary

from_

Return 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.

join(table, *[, onclause, isouter, full])

Add a table or subquery join to the query.

Attributes Documentation

from_

Return 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() Select

Combine all terms into a single query object.

Returns:
sqlsqlalchemy.sql.Select

A SQLAlchemy object representing the full query.

copy() SimpleQuery

Return a copy of this object.

Returns the copy with new lists for the where and columns attributes that can be modified without changing the original.

Returns:
copySimpleQuery

A copy of self.

join(table: FromClause, *, onclause: ColumnElement | None = None, isouter: bool = False, full: bool = False, **kwargs: Any) None

Add a table or subquery join to the query.

Possibly also adding SELECT columns or WHERE expressions at the same time.

Parameters:
tablesqlalchemy.sql.FromClause

Table or subquery to include.

onclausesqlalchemy.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.

isouterbool, optional

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

fullbool, 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.