> ## Documentation Index
> Fetch the complete documentation index at: https://abxbus.archivebox.io/llms.txt
> Use this file to discover all available pages before exploring further.

# SQLiteEventBridge

> Forward events through a local SQLite table with polling.

`SQLiteEventBridge` writes events into a SQLite table and polls for newly inserted rows.

## Go support

<Tabs>
  <Tab title="Go">
    `SQLiteEventBridge` is not implemented in `abxbus-go` yet. Use [JSONLEventBridge](./bridge-jsonl) for the currently supported Go bridge.
  </Tab>

  <Tab title="Rust">
    ```rust theme={null}
    // Not implemented in the Rust crate yet.
    // Use typed event JSON serialization with an external transport for now.
    ```
  </Tab>
</Tabs>

## Constructor params

* `path`: SQLite database file path
* `table`: table name (default `abxbus_events`)
* `poll_interval`: polling interval in seconds (default `0.25`)
* `name`: optional bridge label

<Tabs>
  <Tab title="Python">
    ```python theme={null}
    from abxbus.bridges import SQLiteEventBridge

    bridge = SQLiteEventBridge(
        '/tmp/abxbus_events.sqlite3',
        table='abxbus_events',
        poll_interval=0.25,
        name='SqliteBridge',
    )
    ```
  </Tab>

  <Tab title="TypeScript">
    ```ts theme={null}
    import { SQLiteEventBridge } from 'abxbus/bridges'

    const bridge = new SQLiteEventBridge('/tmp/abxbus_events.sqlite3', 'abxbus_events', 0.25, 'SqliteBridge')
    ```
  </Tab>

  <Tab title="Go">
    ```go theme={null}
    // SQLiteEventBridge is not implemented in abxbus-go yet.
    // Use JSONLEventBridge for Go process-to-process bridge tests and deployments.
    ```
  </Tab>

  <Tab title="Rust">
    ```rust theme={null}
    // Not implemented in the Rust crate yet.
    // Use typed events plus EventBus JSON serialization with an external transport for now.
    ```
  </Tab>
</Tabs>

## Setup with a bus

<Tabs>
  <Tab title="Python">
    ```python theme={null}
    from abxbus import EventBus
    from abxbus.bridges import SQLiteEventBridge

    bus = EventBus('AppBus')
    bridge = SQLiteEventBridge('/tmp/abxbus_events.sqlite3')

    bus.on('*', bridge.emit)
    bridge.on('*', bus.emit)
    ```
  </Tab>

  <Tab title="TypeScript">
    ```ts theme={null}
    import { EventBus } from 'abxbus'
    import { SQLiteEventBridge } from 'abxbus/bridges'

    const bus = new EventBus('AppBus')
    const bridge = new SQLiteEventBridge('/tmp/abxbus_events.sqlite3')

    bus.on('*', bridge.emit)
    bridge.on('*', bus.emit)
    ```
  </Tab>

  <Tab title="Go">
    ```go theme={null}
    // SQLiteEventBridge is not implemented in abxbus-go yet.
    // Use JSONLEventBridge for Go process-to-process bridge tests and deployments.
    ```
  </Tab>

  <Tab title="Rust">
    ```rust theme={null}
    // Not implemented in the Rust crate yet.
    // Use typed events plus EventBus JSON serialization with an external transport for now.
    ```
  </Tab>
</Tabs>

## Behavior

* `emit(...)` upserts event payload fields into the configured table.
* `on(...)` auto-starts polling and registers handlers on the internal bus.
* Columns are created on demand only for `event_*` fields.
* The full event JSON is stored in `event_payload` (not just non-`event_*` fields).
* `event_*` columns are also stored as flat mirrored fields for indexing/querying.
* Writes use SQLite JSON functions for `event_payload` (for example `json(?)`).
* Rehydration merges `event_payload` with `event_*` column values back into a flat event object.
* Rows are read in `(event_created_at, event_id)` order, converted back to events, reset, and emitted locally.
* Runtime notes: Python uses stdlib `sqlite3`; TypeScript requires Node.js with built-in `node:sqlite` (Node 22+).
