atoti.query package

Submodules

atoti.query.auth module

Query Authentication.

atoti.query.auth.Auth = typing.Callable[[str], typing.Union[typing.Mapping[str, str], NoneType]]

Called with the URL of the request and return the HTTP headers necessary to authenticate it.

atoti.query.basic_auth module

Basic Authentication.

class atoti.query.basic_auth.BasicAuthentication(username, password)

Bases: object

Basic Authentication.

It can be used on the server sandbox for instance.

password: str = None
username: str = None

atoti.query.cube module

Query cube.

class atoti.query.cube.QueryCube(name, hierarchies, measures, _session)

Bases: object

Query cube.

hierarchies: QueryHierarchies = None
property levels

Levels of the cube.

Return type

QueryLevels

measures: QueryMeasures = None
name: str = None
query(*measures, levels=None, condition=None, scenario='Base', timeout=30, **kwargs)

Query the cube to get the value of some measures.

The value of the measures is given on all the members of the given levels.

Parameters
  • measures (QueryMeasure) – The measures to query. If none are specified, all the measures are returned.

  • levels (Union[QueryLevel, Sequence[QueryLevel], None]) – The levels to split on. If none are specified, the value of the measures at the top level is returned.

  • condition (Union[LevelCondition, MultiCondition, None]) –

    The filtering condition. Only conditions on level equality with a string are supported. For instance:

    • lvl["Country"] == "France"

    • (lvl["Country"] == "USA") & (lvl["Currency"] == "USD")

  • scenario (str) – The scenario to query.

  • timeout (int) – The query timeout in seconds.

Return type

DataFrame

Returns

The resulting DataFrame.

atoti.query.cubes module

Query cubes.

class atoti.query.cubes.QueryCubes(_data)

Bases: atoti._mappings.ImmutableMapping

Manage the query cubes.

atoti.query.hierarchies module

Query hierarchies.

class atoti.query.hierarchies.QueryHierarchies(_data)

Bases: atoti._mappings.ImmutableMapping

Manage the query hierarchies.

atoti.query.hierarchy module

Query hierarchy.

class atoti.query.hierarchy.QueryHierarchy(name, dimension, levels, slicing)

Bases: object

Hierarchy for query cube.

dimension: str = None
isin(*member_paths)

Return a condition to check that the hierarchy is on one of the given members.

Considering hierarchy_1 containing level_1 and level_2, hierarchy_1.isin((a, x), (b,)) is equivalent to ((level_1 == a) & (level_2 == x)) | (level_1 == b).

Example

Considering a “Geography” hierarchy containing two levels “Country” and “City”, and this measure:

measures["Price in USA/Paris and Germany"] = atoti.filter(
    measures["Price"],
    hierarchies["Geography"].isin(("USA", "Paris"), ("Germany", ))
)

The behavior is the following one:

Country

City

Price

measures[“Price in USA/Paris and Germany”]

France

Paris

200.0

Germany

Berlin

150.0

150.0

UK

London

240.0

USA

New York

270.0

USA

Paris

500.0

500.0

Parameters

members – One or more members expressed as tuples on which the hierarchy should be. Each element in a tuple corresponds to a level of the hierarchy, from the shallowest to the deepest.

Return type

HierarchyIsInCondition

levels: ImmutableMapping[str, QueryLevel] = None
name: str = None
slicing: bool = None

atoti.query.level module

Query level.

class atoti.query.level.QueryLevel(name, dimension, hierarchy)

Bases: object

Level for query cube.

dimension: str = None
hierarchy: str = None
isin(*members)

Return a condition to check that the level is on one of the given members.

levels["x"].isin("a", "b") is equivalent to levels["x"] == "a" OR levels["x"] == "b".

Example

Considering this measure:

measures["Price in Paris and London"] = atoti.filter(
    measures["Price"],
    levels["City"].isin("Paris", "London")
)

The behavior is the following one:

City

Price

measures[“Price in Paris and London”]

Paris

200.0

200.0

Berlin

150.0

London

240.0

240.0

New York

270.0

Parameters

members (Any) – One or more members on which the level should be.

Return type

LevelIsInCondition

name: str = None

atoti.query.levels module

Query levels.

class atoti.query.levels.QueryLevels(_hierarchies)

Bases: atoti._base_levels.BaseLevels

Flat representation of all the levels in the cube.

atoti.query.measure module

Query measure.

class atoti.query.measure.QueryMeasure(name, visible, folder, formatter)

Bases: object

Query measure.

folder: Optional[str] = None
formatter: Optional[str] = None
name: str = None
visible: bool = None

atoti.query.measures module

Query measures.

class atoti.query.measures.QueryMeasures(_data)

Bases: atoti._mappings.ImmutableMapping

Manage the query measures.

atoti.query.session module

Making MDX queries on existing sessions.

class atoti.query.session.QuerySession(url, auth, name)

Bases: object

Used to query an existing session.

property cubes

Cubes of the session.

Return type

QueryCubes

property name

Name of the session.

Return type

str

query_mdx(mdx, *, timeout=30, **kwargs)

Execute an MDX query and return its result as a pandas DataFrame.

Parameters
  • mdx (str) –

    The MDX SELECT query to execute. Requirements to guarantee that the DataFrame is well shaped:

    • No more than two axes.

    • No grand or sub totals.

    • Nothing else but measures on the COLUMNS axis.

  • timeout (int) – The query timeout in seconds.

Return type

DataFrame

property url

URL of the session.

Return type

str

Module contents

Package to query an existing session.

atoti.query.open_query_session(url, name=None, *, auth=None)

Open an existing session to query it.

Parameters
  • url (str) – The server base URL, if {url} is given, {url}/versions/rest is expected to exist.

  • name (Optional[str]) – The name to give to the session. Defaults to the passed url.

  • auth (Optional[Callable[[str], Optional[Mapping[str, str]]]]) – The authentication to use.

Return type

QuerySession

Returns

The query session.