crandas.base¶
- class crandas.base.Session(base_path=None, **kwargs)¶
Bases:
object
This object stores the state specific to the connection to the VDL server. By default, the connect() method is invoked lazily, on the first crandas method that requires a connection to the VDL. Because of this, the user can first configure the variables; for example:
>>> import crandas >>> from crandas.base import session >>> session.endpoint = "https://example.com:10000/api/v1" >>> session.base_path = Path("/cranmera") >>> crandas.DataFrame({})
- Raises:
ServerError – Passes through error from VDL and appropriate error code
ServerError – Passes through error from VDL in case error code is not known
- property base_path: Path | None¶
The base ‘cranmera’ folder. When None, the application tries to find a parent of the current directory called ‘cranmera’, or defaults to the current directory.
- connect(connection_file=None)¶
Establishes a connection with the query server and verifies whether the client and server versions are compatible.
- Parameters:
connection_file (str | Path | file-like object) –
A (path to a) VDL connection file.
It may be specified as string not containing slashes (/), backslashes () or dots (.), in which case it is interpreted as a “{name}.vdlconn” file located in the configuration folder. By default, the configuration folder is
~/.config/crandas
– this can also be modified by some environment variables, seecrandas.config
.If it is a string that contains slashes, backslashes or dots, it is assumed to be a path, either a relative path for the current working directory, or an absolute path.
- read_analyst_key()¶
Read the analyst’s key, that is used to ensure that only some designated analysts can execute an approved query, for the current session.
- reset()¶
Disconnects and resets the current session.
Use this command if the MPC servers have been restarted.