Skip to Content

Features

Watch a database

Capture new and updated rows from your database tables as memories.

Much of what your app knows lands in its database first: orders, tickets, account changes. watch checks the tables you choose on a schedule and captures new and updated rows.

Watch a database when...

  • The facts you want to remember are written to tables by several services.
  • Changing every service to call capture isn't practical.

Availability

SDKAvailable
PythonYes
TypeScriptNo. Call capture where rows are written, or use instrument.

Set it up

import os
from docklee import Dock

dock = Dock()
dock.watch(
    connection_string=os.environ["ORDERS_DATABASE_URL"],
    tables=["orders", "support_tickets"],
    poll_interval=10,
)

watch runs in a background thread, so the call returns at once and your app keeps running.

Options

OptionDefaultDescription
connection_stringnoneHow to connect to the database.
tablesnoneThe tables to watch.
poll_interval5Seconds between checks.
capture_insertsTrueCapture new rows.
capture_updatesTrueCapture changed rows.

Use a read-only database user, and read the connection string from the environment. Watch only tables whose rows are safe to remember.

Next steps

Your tables are watched. Capture events from outside tools next.

On this page