connection module

get_connection(**kwargs)

Getter function to get the ibis connection object.

Parameters:

**kwargs (Any) – Leaves room for connections that require keyword arguments.

Yields:

conn – Connection object, primarily an ibis.Backend object.

Return type:

Iterator[BaseBackend]

Example

with get_connection() as conn:

t = conn.table(‘datatable’) t.select([*variables]).to_pandas()

Raises:

ValueError – If no connection has been set using ‘set_connection()’.

Parameters:

kwargs (Any)

Return type:

Iterator[BaseBackend]

set_connection(connection_func, is_pooled=False)

Setter function to set the function for generating ibis connection objects.

Parameters:
  • connection_func (Callable[..., AbstractContextManager[BaseBackend]]) – Callable that needs to provide an ibis connection using ‘@contextmanager’ decorator that and yielding an ibis connection.

  • is_pooled (bool) – Indicates if the connection method utilizes pooling. Defaults to False.

Raises:

TypeError – If yielded connection object is not an ibis.BaseBackend object.

Return type:

None

set_parquedit_connection(test_dir_path=None)
Parameters:

test_dir_path (Path | None)

set_postgres_connection(database_url, pool_min_size=1, pool_max_size=1, configure=None)

Helper function to configure a pooled connection to a postgres database.

Parameters:
  • database_url (str) – Connection url for the database. Gets passed to psycopg_pool.ConnectionPool as conninfo argument.

  • pool_min_size (int) – The minimum size of the pool. Defaults to 1.

  • pool_max_size (int) – The maximum size of the pool. Defaults to 1.

  • configure (Callable[[Connection], None] | None) – Optional callback the pool runs on every new connection, receiving the raw psycopg.Connection. Use it for per-connection session setup that must apply to all pooled connections – e.g. setting a session GUC for an audit trail (SET ...) when pool_max_size > 1. Passed straight through to psycopg_pool.ConnectionPool; defaults to None (no-op), so existing callers are unaffected.

Return type:

None

set_sqlite_connection(database_path)

Helper function to configure a connection to a SQLite database.

Parameters:

database_path (str) – Path to the SQLite database file. Use “:memory:” for an in-memory database.

Return type:

None