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
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: str

query instance-attribute

query: str

PQLFilter

Bases: SaolaPyBaseModel

Class representing PQL filter.

Attributes:

  • query (str) –

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

query instance-attribute

query: str

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: str

ascending class-attribute instance-attribute

ascending: bool = 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[pydantic.NonNegativeInt]) –

    Output rows are limited to limit rows. If None, all rows are returned.

  • offset (Optional[pydantic.NonNegativeInt]) –

    Output skips offset first rows. If None, no rows are skipped.

columns class-attribute instance-attribute

columns: List[PQLColumn] = Field(default_factory=list)

filters class-attribute instance-attribute

filters: List[PQLFilter] = Field(default_factory=list)

order_by_columns class-attribute instance-attribute

order_by_columns: List[OrderByColumn] = Field(
    default_factory=list
)

distinct class-attribute instance-attribute

distinct: bool = False

limit instance-attribute

limit: Optional[pydantic.NonNegativeInt]

offset instance-attribute

offset: Optional[pydantic.NonNegativeInt]

queries property

queries: List[str]

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.