queries.BaseQuery
Base class for all query types.
Usage
queries.BaseQuery(table)Methods
| Name | Description |
|---|---|
| __init__() | Initialize a new query. |
| __repr__() | Get nice string representation. |
| by_muid() | Filter the query by one or more MUIDs. |
| execute() | Execute the query against the database. |
| reset() | Reset the query execution status to allow re-execution. |
| where() | Add a WHERE condition to the query. |
__init__()
Initialize a new query.
Usage
__init__(table)Parameters
table: BaseTable- The table this query operates on
__repr__()
Get nice string representation.
Usage
__repr__()Returns
str- The query type, table name and whether it has been executed.
by_muid()
Filter the query by one or more MUIDs.
Usage
by_muid(muid_or_muids)Parameters
muid_or_muids: str or list/tuple of str- A single MUID string, or a list/tuple of MUID strings.
Returns
self- The query instance for method chaining.
Raises
ValueError-
If
muid_or_muidsis not a string, or a list/tuple of strings, or if items in list/tuple are not strings. ValueError-
If
muid_or_muidsis an empty list/tuple.
execute()
Execute the query against the database.
Usage
execute()Template method that handles execution tracking and delegates to _execute_impl for the actual query execution.
Returns
QueryResultT- Query-type dependent result
Raises
RuntimeError-
If the query has already been executed
ValueError- If the database is not open
reset()
Reset the query execution status to allow re-execution.
Usage
reset()Returns
self- For method chaining
where()
Add a WHERE condition to the query.
Usage
where(condition)Parameters
condition: str- SQL-like condition string
Returns
self- For method chaining