atoti.Session.connect#
- classmethod Session.connect(url, *, authentication=None, certificate_authority=None)#
Connect to an existing session.
Here is a breakdown of the capabilities of the returned session:
Local
If all the following conditions are met:
the target session requires authentication (e.g. it has
securityconfigured)
the provided authentication or certificate_authority arguments grant ROLE_ADMIN
the target session (the one at url) was
startedwith the same version of Atoti Python SDK (0.9.10)
the target session runs on the same host as the current Python process
Then all
Sessioncapabilities can be used except for:
Remote
If conditions a., b., and c. are met but not d. (i.e., not on the same host)
Then all local capabilities are available except those needing a shared file system. For example:
load()withCsvLoadorParquetLoad,read_csv(), andread_parquet()are not available (unless loading from cloud storage)load()withpyarrow.Tableorpandas.DataFrame,read_arrow()andread_pandas()methods are not available
No security management
If conditions a. and b. are meet, plus both:
the target session runs the same Atoti Server version (e.g. 6.1.13 for Atoti Python SDK 0.9.10)
the target session is exposed to Atoti Python SDK
Depending on whether d. is met, either local or remote capabilities are available, except for
securitymanagement features.
Read-only
If only condition e. is met (i.e. matching Atoti Server versions)
Then capabilities that modify the session data or data model are unavailable. However, some read-only capabilities remain accessible. For example:
Not available:
create_table(),create_cube(), andread_csv()Available:
atoti.tables.Tables.schemaandatoti.Table.query()
Minimal capabilities
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:
Self
Example
>>> session_config = tt.SessionConfig(security=tt.SecurityConfig()) >>> target_session = tt.Session.start(session_config) >>> _ = target_session.create_table("Example", data_types={"Id": "String"}) >>> target_session.security.individual_roles.update( ... {"user": {"ROLE_USER"}, "admin": {"ROLE_USER", "ROLE_ADMIN"}}, ... ) >>> password = "passwd" >>> target_session.security.basic_authentication.credentials.update( ... {"user": password, "admin": password} ... ) >>> admin_session = tt.Session.connect( ... target_session.url, ... authentication=tt.BasicAuthentication("admin", password), ... ) >>> table = admin_session.tables["Example"] >>> table += ("foo",) >>> table.head() Id 0 foo
The connected session must be granted ROLE_ADMIN:
>>> user_session = tt.Session.connect( ... target_session.url, ... authentication=tt.BasicAuthentication("user", password), ... ) >>> user_session.ready = False Traceback (most recent call last): ... atoti._graphql.client.exceptions.GraphQLClientHttpError: HTTP status code: 400
See also