Loading...

vastorbit.connection.current_connection

vastorbit.connection.current_connection() Any

Returns the current database connection. If the connection is closed, vastorbit attempts to reconnect with the existing connection.

If the connection attempt fails, vastorbit attempts to reconnect using stored credentials. If this also fails, vastorbit attempts to connect using an auto connection. Otherwise, vastorbit attempts to connect to a VASTLab Environment.

Examples

Get the current vastorbit connection:

from vastorbit.connection import current_connection

conn = current_connection()
conn

<trino.dbapi.Connection object at 0x118c1f8d0>

After the connection is established, you can execute SQL queries directly:

Note

Please refer to your connector’s API reference for a comprehensive list of its functionalities.

conn.cursor().execute("SELECT version()").fetchone()

['Trino version 450']

See also

current_cursor() : Returns the current vastorbit cursor.
new_connection() : Creates a new vastorbit connection.
set_connection() : Sets the vastorbit connection.