atoti.query package

Submodules

atoti.query.auth module

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

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

Bases: object

Basic Authentication.

password: str = None
username: str = None
atoti.query.basic_auth.create_basic_authentication(username, password)

Create a basic authentication.

It can be used on ActivePivots’s sandbox for instance.

Return type

Callable[[str], Optional[Mapping[str, str]]]

atoti.query.cube module

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

Bases: object

Query cube.

name

Cube name.

hierarchies

Cube hierarchies.

measures

Cube measures.

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

QueryResult

Returns

The resulting DataFrame.

atoti.query.cubes module

class atoti.query.cubes.QueryCubes(_data)

Bases: atoti._mappings.ImmutableMapping

Manage the query cubes.

atoti.query.hierarchies module

class atoti.query.hierarchies.QueryHierarchies(_data)

Bases: atoti._mappings.ImmutableMapping

Manage the query hierarchies.

atoti.query.hierarchy module

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

Bases: object

Hierarchy for query cube.

name

Hierarchy name.

dimension

Hierarchy dimension.

levels

Levels of the hierarchy.

slicing

Whether the hierarchy is slicing or not.

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

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

Bases: object

Level for query cube.

name

Level name.

dimension

Dimension of the level’s hierarchy.

hierarchy

Hierarchy the level is member of.

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

class atoti.query.levels.QueryLevels(_hierarchies)

Bases: atoti._base_levels.BaseLevels

Flat representation of all the levels in the cube.

atoti.query.measure module

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

Bases: object

Query measure.

name

Measure name.

visible

Whether the measure is visible or not.

folder

Measure folder.

formatter

Measure formatter.

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

atoti.query.measures module

class atoti.query.measures.QueryMeasures(_data)

Bases: atoti._mappings.ImmutableMapping

Manage the query measures.

atoti.query.query_result module

class atoti.query.query_result.QueryResult(data=None, index=None, columns=None, *, cube, context=None, formatted_values, get_styler, mdx=None)

Bases: pandas.core.frame.DataFrame

Custom pandas DataFrame that can be converted to a widget by our JupyterLab extension.

property style

Return a Styler object.

If the DataFrame has not been changed in place since its creation, the returned object will follow the styling included in the cellset from which the DataFrame was converted.

Return type

Styler

atoti.query.session module

exception atoti.query.session.HttpException(parent)

Bases: Exception

Exception representing and HTTP error.

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

QueryResult

property url

URL of the session.

Return type

str

Module contents

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

Open an existing session to query it.

This can be used to connect to:

  • Other sessions built with another atoti process

  • ActivePivot cubes built with a classic Java project, if version >= 5.7.0

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.