Loading...

vastorbit.connection.read_dsn

vastorbit.connection.read_dsn(section: str, dsn: str | None = None) Dict[str, Any]

Reads the DSN information from the vastorbit_CONNECTION environment variable or the input file.

Parameters:
  • section (str) – Name of the section in the configuration file that contains the credentials.

  • dsn (str, optional) – Path to the file containing the credentials.If empty, the vastorbit_CONNECTION environment variable is used.

Returns:

dictionary with all the credentials.

Return type:

dict

Examples

Read the DSN information from the connection file:

from vastorbit.connection import read_dsn

dsn = read_dsn("VASTDSN")
dsn
{
'database': 'testdb',
'host': '10.211.55.14',
'password': 'XxX',
'port': 8080,
'user': 'dbadmin'
}

Read the DSN information from a input file:

dsn = read_dsn(
    "vp_test_config",
    "/Users/Badr/Library/Python/3.6/lib/python/site-packages/vastorbit/tests/vastorbit_test.conf",
)
dsn
{
'password': 'XxX',
'port': 8080,
'user': 'dbadmin',
'vp_test_database': 'testdb',
'vp_test_host': '10.211.55.14',
'vp_test_log_dir': 'mylog/vp_tox_tests_log',
'vp_test_password': 'XxX',
'vp_test_port': '8080',
'vp_test_user': 'dbadmin'
}

See also

get_connection_file() : Gets the vastorbit connection file.
new_connection() : Creates a new vastorbit connection.
set_connection() : Sets the vastorbit connection.