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]:
<vertica_python.vertica.connection.Connection at 0x118c1f8d0>
In [16]:
conn.cursor().execute("SELECT version();").fetchone()
Out[16]:
['Vertica Analytic Database v11.0.1-0']