current_connection¶
In [ ]:
current_connection()
Returns the current database connection. If the connection is closed, VerticaPy attempts to reconnect with the existing connection.
If the connection attempt fails, VerticaPy attempts to reconnect using stored credentials. If this also fails, VerticaPy attempts to connect using an auto connection. Otherwise, VerticaPy attempts to connect to a VerticaLab Environment.
Example¶
In [15]:
from verticapy.connect import current_connection
conn = current_connection()
conn
Out[15]:
In [16]:
conn.cursor().execute("SELECT version();").fetchone()
Out[16]: