verticapy.connection.new_connection#
- verticapy.connection.new_connection(conn_info: dict, name: str = 'vertica_connection', auto: bool = True, overwrite: bool = True) None #
Saves the new connection in the VerticaPy 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
dictionnary
containing the information to set up the connection.- database:
Database Name.
- host:
Server ID.
- password:
User Password.
- port:
Database Port (optional, default: 5433).
- user:
User ID (optional, default: dbadmin).
…
- env:
bool
to indicate whether the user and password are replaced by the associated environment variables. IfTrue
, VerticaPy 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 VerticaPy 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
True
and the connection already exists, the existing connection will be overwritten.
Examples#
Create a new connection to VerticaPy:
Note
If no errors are raised, the new connection was successful.
from verticapy.connection import new_connection conn_info = { "host": "10.211.55.14", "port": "5433", "database": "testdb", "password": "XxX", "user": "dbadmin", } new_connection(conn_info, name = "VerticaDSN")
See also
get_connection_file()
: Gets the VerticaPy connection file.set_connection()
: Sets the VerticaPy connection.