base
Module to interact with PQL queries.
This module contains class to interact with PQL queries including columns and filters.
Typical usage example:
```python
query = PQL(distinct=True)
query += PQLColumn(name="column", query='"TABLE"."COLUMN"')
query += PQLFilter(query='FILTER "TABLE"."COLUMN" = 1;')
query += OrderByColumn(query='"TABLE"."COLUMN"', ascending=False)
```
PQLColumn ¶
PQLFilter ¶
Bases: SaolaPyBaseModel
Class representing PQL filter.
Attributes:
-
query
(str
) –Query of PQL filter. Needs to have format 'FILTER CONDITION;'.
OrderByColumn ¶
Bases: SaolaPyBaseModel
Class representing order by column used to order results of query.
Attributes:
PQL ¶
Bases: SaolaPyBaseModel
Class representing PQL query that can be used for data export.
Attributes:
-
columns
(List[PQLColumn]
) –PQLColumn objects of query representing columns of query.
-
filters
(List[PQLFilter]
) –PQLFilter objects of query filtering result.
-
order_by_columns
(List[OrderByColumn]
) –OrderByColumns used to sort result. First column is most important and last column least important.
-
distinct
(bool
) –If true, result only contains distinct rows and no duplicates.
-
limit
(Optional[NonNegativeInt]
) –Output rows are limited to
limit
rows. If None, all rows are returned. -
offset
(Optional[NonNegativeInt]
) –Output skips
offset
first rows. If None, no rows are skipped.
order_by_columns
class-attribute
instance-attribute
¶
queries
property
¶
Returns list of string queries that can be used to export data.
Returns:
-
List[str]
–List of query strings.
add ¶
Adds object to PQL object depending on object type.
Parameters:
-
obj
(Union[PQLColumn, PQLFilter, Iterable[Union[PQLColumn, PQLFilter, OrderByColumn]]]
) –Object to add to PQL query. Can be either PQLColumn, PQLFilter, OrderByColumn, or a list of these objects.
Raises:
-
TypeError
–Raised if object type does not match supported types.