Loading...

verticapy.connection.read_dsn#

verticapy.connection.read_dsn(section: str, dsn: str | None = None) dict#

Reads the DSN information from the VERTICAPY_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 VERTICAPY_CONNECTION environment variable is used.

Returns#

dict

dictionary with all the credentials.

Examples#

Read the DSN information from the ODBCINI environment variable:

from verticapy.connection import read_dsn

dsn = read_dsn("VerticaDSN")
dsn
{
'database': 'testdb',
'description': 'DSN for Vertica',
'driver': '/Library/Vertica/ODBC/lib/libverticaodbc.dylib',
'host': '10.211.55.14',
'kerberos_host_name': 'badr',
'password': 'XxX',
'port': '5433',
'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/verticapy/tests/verticaPy_test.conf",
)
dsn
{
'password': 'XxX',
'port': 5433,
'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': '5433',
'vp_test_user': 'dbadmin'
}

See also

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