vastorbit.connection.new_connection¶
- vastorbit.connection.new_connection(conn_info: Dict[str, Any], name: str = 'vast_connection', auto: bool = True, overwrite: bool = True, connect_attempt: bool = True, prompt: bool = False) None¶
Saves the new connection in the vastorbit connection file. The information is saved as plaintext in the local machine. The function
get_connection_file()returns the associated connection file path. If you want a temporary connection, you can use theset_connection()function.- Parameters:
conn_info (dict) –
dictionarycontaining the information to set up the connection.- catalog:
Trino catalog name (default: vast).
- schema:
Trino schema name (default: default).
- host:
Server hostname or IP.
- port:
Server port (default: 8080).
- user:
Username (default: admin).
- password:
User password (optional).
- http_scheme:
HTTP scheme: http or https (default: http).
…
- env:
boolto indicate whether the user and password are replaced by the associated environment variables. IfTrue, vastorbit reads the associated environment variables instead of writing and directly using the username and password. For example:{'user': 'ENV_USER', 'password': 'ENV_PASSWORD'}This works only for the user and password. The real values of the other variables are stored plaintext in the vastorbit connection file. Using the environment variables hides the username and password in cases where the local machine is shared.
name (str, optional) – Name of the connection.
auto (bool, optional) – If set to True, the connection will become the new auto-connection.
overwrite (bool, optional) – If set to
Trueand the connection already exists, the existing connection will be overwritten.connect_attempt (bool) – If set to False, it will not attempt to connect automatically.
prompt (bool, optional) – If set to True, it will open a prompt to ask for
oauth_refresh_tokenas well asclient_secret.
Examples
Create a new connection to vastorbit:
Note
If no errors are raised, the new connection was successful.
from vastorbit.connection import new_connection conn_info = { "host": "10.211.55.14", "port": "8080", "catalog": "vast", "schema": "default", "user": "admin", } new_connection(conn_info, name = "VASTDSN")
See also
get_connection_file(): Gets the vastorbit connection file.set_connection(): Sets the vastorbit connection.