Loading...

vastorbit.connection.set_connection

vastorbit.connection.set_connection(conn: Any) None

Saves a custom connection to the vastorbit object. This allows you to specify, for example, a custom Trino connection. This should not be confused with a native vastorbit connection created by the new_connection() function.

Examples

Create a connection using the Trino Python client:

Note

You can use any connector as long as it has both fetchone and fetchall methods (DBAPI 2.0 compliant).

import trino

conn = trino.dbapi.connect(
    host='10.211.55.14',
    port=8080,
    user='admin',
    catalog='vast',
    schema='default',
)

Set up the connector:

Warning

As this connector is used throughout the entire API, if it’s closed, you’ll need to create a new one. This is why, in some cases, it’s better to use auto-connection, which automatically creates a new connection if the current one is closed.

from vastorbit.connection import set_connection

set_connection(conn)

See also

new_connection() : Creates a new vastorbit connection.