maestral.database.query

SQL query definitions that facilitate writing object-oriented code to generate SQL queries.

Module Contents

class maestral.database.query.Query[source]

Base type for query

abstract clause(self)[source]

Generate the corresponding SQL clause.

Returns

SQL clause and arguments to substitute.

Return type

tuple[str, Sequence]

class maestral.database.query.PathTreeQuery(column, path)[source]

Bases: Query

Query for an entire subtree at the given path.

Parameters
clause(self)[source]

Generate the corresponding SQL clause.

Returns

SQL clause and arguments to substitute.

class maestral.database.query.MatchQuery(column, value)[source]

Bases: Query

Query to match an exact value.

Parameters
clause(self)[source]

Generate the corresponding SQL clause.

Returns

SQL clause and arguments to substitute.

class maestral.database.query.AllQuery[source]

Bases: Query

Query to match everything.

clause(self)[source]

Generate the corresponding SQL clause.

Returns

SQL clause and arguments to substitute.

class maestral.database.query.CollectionQuery(*subqueries)[source]

Bases: Query

An abstract query class that aggregates other queries. Can be indexed like a list to access the sub-queries.

Parameters

subqueries (Query) – Subqueries to aggregate.

clause_with_joiner(self, joiner)[source]

Return a clause created by joining together the clauses of all subqueries with the string joiner (padded by spaces).

Parameters

joiner (str) –

Return type

tuple[str, Sequence]

abstract clause(self)[source]

Generate the corresponding SQL clause.

Returns

SQL clause and arguments to substitute.

class maestral.database.query.AndQuery(*subqueries)[source]

Bases: CollectionQuery

A conjunction of a list of other queries.

Parameters

subqueries (Query) –

clause(self)[source]

Generate the corresponding SQL clause.

Returns

SQL clause and arguments to substitute.

class maestral.database.query.OrQuery(*subqueries)[source]

Bases: CollectionQuery

A conjunction of a list of other queries.

Parameters

subqueries (Query) –

clause(self)[source]

Generate the corresponding SQL clause.

Returns

SQL clause and arguments to substitute.

class maestral.database.query.NotQuery(subquery)[source]

Bases: Query

A query that matches the negation of its subquery, as a shorcut for performing not(subquery) without using regular expressions.

Parameters

subquery (Query) – Query to negate.

clause(self)[source]

Generate the corresponding SQL clause.

Returns

SQL clause and arguments to substitute.