vgi.transactor
Module overview
db-transactor — transactional database access for VGI workers.
The transactor is a long-lived subprocess that owns a single DuckDB
connection. VGI worker processes communicate with it via vgi_rpc
over Unix domain sockets, using the same streaming exchange patterns
that DuckDB uses with VGI workers.
Architecture:
VGI Worker(s) ──── vgi_rpc (Unix socket) ──── db-transactor │ DuckDB fileclass TransactorClient
Section titled “class TransactorClient”Description
Client that connects to (and optionally spawns) a db-transactor.
The transactor process is auto-spawned on first use if not already running. A single transactor serves all databases.
Methods
method get_proxy
Section titled “method get_proxy”get_proxy() -> AnyGet the typed RPC proxy, spawning the transactor if needed.
class TransactorProtocol
Section titled “class TransactorProtocol”Bases: Protocol
Description
RPC interface for the db-transactor subprocess.
Methods
method register
Section titled “method register”register(
attach_opaque_data: bytes,
catalog_name: str = ‘’,
ddl_statements: list[str] | None = None,
) -> NoneRegister a new database for this attach_opaque_data and run initial DDL.
method catalog_version
Section titled “method catalog_version”catalog_version(attach_opaque_data: bytes) -> intReturn the catalog version for the database (incremented on DDL).
method begin
Section titled “method begin”begin(attach_opaque_data: bytes) -> bytesBegin a transaction. Returns the transactor-generated tx_id.
method commit
Section titled “method commit”commit(attach_opaque_data: bytes, tx_id: bytes) -> NoneCommit a transaction.
method rollback
Section titled “method rollback”rollback(attach_opaque_data: bytes, tx_id: bytes) -> NoneRollback a transaction.
method insert
Section titled “method insert”insert(
attach_opaque_data: bytes,
tx_id: bytes,
table_name: str,
schema_name: str = ‘’,
returning: bool = False,
) -> Stream[ExchangeState]Insert rows into a table via lockstep exchange.
method delete
Section titled “method delete”delete(
attach_opaque_data: bytes,
tx_id: bytes,
table_name: str,
schema_name: str = ‘’,
returning: bool = False,
) -> Stream[ExchangeState]Delete rows from a table via lockstep exchange.
method update
Section titled “method update”update(
attach_opaque_data: bytes,
tx_id: bytes,
table_name: str,
schema_name: str = ‘’,
columns: list[str] | None = None,
returning: bool = False,
) -> Stream[ExchangeState]Update rows in a table via lockstep exchange.
method scan
Section titled “method scan”scan(
attach_opaque_data: bytes,
tx_id: bytes,
table_name: str,
columns: list[str],
schema_name: str = ‘’,
pushdown_filters: bytes | None = None,
) -> Stream[ProducerState]Scan rows from a table with optional predicate pushdown.
method execute_ddl
Section titled “method execute_ddl”execute_ddl(attach_opaque_data: bytes, sql: str) -> NoneExecute a DDL statement on the database (non-transactional).
method execute_ddl_tx
Section titled “method execute_ddl_tx”execute_ddl_tx(
attach_opaque_data: bytes,
tx_id: bytes,
sql: str,
strip_catalog: str | None = None,
) -> NoneExecute DDL within a transaction.
method list_schemas
Section titled “method list_schemas”list_schemas(attach_opaque_data: bytes, tx_id: bytes) -> list[str]List schema names within a transaction.
method list_user_tables
Section titled “method list_user_tables”list_user_tables(
attach_opaque_data: bytes,
tx_id: bytes,
schema_name: str = ‘main’,
) -> list[str]List user-created table names in the given schema within a transaction.
method table_schema
Section titled “method table_schema”table_schema(
attach_opaque_data: bytes,
table_name: str,
tx_id: bytes,
) -> bytesGet Arrow schema for a table as serialized IPC bytes.
method table_comment
Section titled “method table_comment”table_comment(
attach_opaque_data: bytes,
table_name: str,
tx_id: bytes,
) -> str | NoneGet the comment on a table, or None if no comment is set.
method list_user_views
Section titled “method list_user_views”list_user_views(
attach_opaque_data: bytes,
tx_id: bytes,
schema_name: str = ‘main’,
) -> list[str]List user-created view names in the given schema within a transaction.
method view_info
Section titled “method view_info”view_info(
attach_opaque_data: bytes,
view_name: str,
tx_id: bytes,
) -> strGet view info as JSON (definition, comment).