Skip to content

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

Bases: SaolaPyBaseModel

Class representing PQL column of OLAP table.

Attributes:

  • name (str) –

    Name of the column.

  • query (str) –

    PQL query of the column.

name instance-attribute

name

query instance-attribute

query

PQLFilter

Bases: SaolaPyBaseModel

Class representing PQL filter.

Attributes:

  • query (str) –

    Query of PQL filter. Needs to have format 'FILTER CONDITION;'.

query instance-attribute

query

OrderByColumn

Bases: SaolaPyBaseModel

Class representing order by column used to order results of query.

Attributes:

  • query (str) –

    Query of order by column.

  • ascending (bool) –

    Whether results should be sorted ascending or descending. Default True.

query instance-attribute

query

ascending class-attribute instance-attribute

ascending = True

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.

columns class-attribute instance-attribute

columns = Field(default_factory=list)

filters class-attribute instance-attribute

filters = Field(default_factory=list)

order_by_columns class-attribute instance-attribute

order_by_columns = Field(default_factory=list)

distinct class-attribute instance-attribute

distinct = False

limit instance-attribute

limit

offset instance-attribute

offset

queries property

queries

Returns list of string queries that can be used to export data.

Returns:

  • List[str]

    List of query strings.

add

add(obj)

Adds object to PQL object depending on object type.

Parameters:

Raises:

  • TypeError

    Raised if object type does not match supported types.