atoti.Session.connect#
- classmethod Session.connect(url, *, authentication=None, certificate_authority=None)#
Connect to an existing session.
Here is a breakdown of the Live Extension capabilities available on the returned session:
Local
If the conditions:
the target session requires authentication (e.g. it has
security
configured)
the passed authentication or certificate_authority arguments grant ROLE_ADMIN
the target session (the one at url) was
started
with the same version of Atoti Python API (0.9.1)
the target session runs on the same host as the current Python process
are all met, then all the capabilities of
Session
are available except forlogs_path
,endpoint()
, andwait()
.Remote
If conditions a., b., and c. but not d. (as defined previously) are met, all the Local capabilities are available except for methods relying on a shared file system:
load_csv()
,read_csv()
,load_parquet()
,read_parquet()
unless loading from cloud storageappend()
,load_arrow()
,load_numpy()
,load_pandas()
,load_spark()
(and the correspondingread_*()
methods)
No security management
If conditions a., b. and:
the target session has the same Atoti Server version as the one of sessions created with
start()
(6.1.1 for Atoti Python API 0.9.1)
the target session exposes itself to Atoti Python API
are met then, depending on d., either Local or Remote capabilities are available except for
security
management.Read-only
If only condition e. is met, none of the capabilities modifying the session’s data or data model are available but some read-only capabilities are. For instance:
not available:
create_table()
,create_cube()
, andread_csv()
available:
atoti.tables.Tables.schema
andatoti.Table.query()
Minimal
atoti.Session.link
,atoti.Session.query_mdx
, andatoti.Cube.query
are always available.
Note
Data and data model changes made from a connected session are not persisted on the target session. They will be lost if the target session is restarted.
- Parameters:
url (str) – The base URL of the target session. The endpoint
f"{url}/versions/rest"
is expected to exist.authentication (Authenticate | ClientCertificate | None) – The method used to authenticate against the target session.
certificate_authority (Path | None) – Path to the custom certificate authority file to use to verify the HTTPS connection. Required when the target session has been configured with an SSL certificate that is not signed by some trusted public certificate authority.
- Return type:
Example
>>> session_config = tt.SessionConfig(security=tt.SecurityConfig()) >>> secure_session = tt.Session.start(session_config) >>> _ = secure_session.create_table("Example", types={"Id": "String"}) >>> secure_session.security.basic_authentication.credentials.update( ... {"user": "passwd", "admin": "passwd"} ... ) >>> secure_session.security.individual_roles.update( ... {"user": {"ROLE_USER"}, "admin": {"ROLE_USER", "ROLE_ADMIN"}} ... ) >>> admin_session = tt.Session.connect( ... secure_session.url, ... authentication=tt.BasicAuthentication("admin", "passwd"), ... ) >>> table = admin_session.tables["Example"] >>> table += ("foo",) >>> table.head() Id 0 foo
Live Extension requires the connected session to be granted ROLE_ADMIN:
>>> user_session = tt.Session.connect( ... secure_session.url, ... authentication=tt.BasicAuthentication("user", "passwd"), ... ) >>> list(user_session.tables) Traceback (most recent call last): ... atoti._live_extension_unavailable_error.LiveExtensionUnavailableError: Live extension is not available ...
Live Extension requires the target session to be secure:
>>> unsecure_session = tt.Session.start() >>> _ = unsecure_session.create_table("Example", types={"Id": "String"}) >>> connected_session = tt.Session.connect(unsecure_session.url) >>> list(connected_session.tables) Traceback (most recent call last): ... atoti._live_extension_unavailable_error.LiveExtensionUnavailableError: Live extension is not available ...
See also