Docs
GuidesWebsite GitHub
OverviewGetting StartedTry the Demo DatabaseApprove a Database WriteTerminal and CLIBackground Host
AgentConversationsConfigurationAuthenticationLLM ProvidersToolsPython Analysis
Data SourcesSQLitePostgreSQLFiles and FoldersHTTP APIsQueryingCatalogDatabase WritesRemote MCP ToolsPrivate Database
Work BoardArtifactsJobsRoutines
Memory and LearningSemanticsSkills
Observation EventsError HandlingEvaluation
Daita / Docs
OverviewGetting StartedTry the Demo DatabaseApprove a Database WriteTerminal and CLIBackground Host
AgentConversationsConfigurationAuthenticationLLM ProvidersToolsPython Analysis
Data SourcesSQLitePostgreSQLFiles and FoldersHTTP APIsQueryingCatalogDatabase WritesRemote MCP ToolsPrivate Database
Work BoardArtifactsJobsRoutines
Memory and LearningSemanticsSkills
Observation EventsError HandlingEvaluation

Daita Agents · Guide

Approve a Database Write

Attach PostgreSQL, enable one table for updates, approve an exact preview and inspect the receipt.

#Goal

Let an agent change rows in one PostgreSQL table, with you approving the exact statement and Daita recording what happened. Attaching a database never grants write access.

#Prerequisites

  • Daita Agents installed and an agent named atlas with a model.
  • A non-production PostgreSQL database. Verify backups and recovery before you use a real one.
  • A password in an environment variable, never in a prompt.

#1. Create a least-privileged role

Create it outside Daita. Do not use an owner, superuser or BYPASSRLS role.

sql
CREATE ROLE daita_writer LOGIN
    NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT NOREPLICATION NOBYPASSRLS;
 
GRANT CONNECT ON DATABASE application_db TO daita_writer;
GRANT USAGE ON SCHEMA support TO daita_writer;
GRANT SELECT ON TABLE support.tickets TO daita_writer;
GRANT UPDATE (priority) ON TABLE support.tickets TO daita_writer;

The role needs SELECT because Daita previews and rechecks the rows.

#2. Attach the database

bash
export DAITA_PG_PASSWORD='...'
daita attach atlas postgresql \
  --host db.example.com --database application_db --username daita_writer \
  --password-env DAITA_PG_PASSWORD --schema support --source-name Support
daita sources atlas

Note the source ID from daita sources. The source is read-only so far.

#3. Enable updates on one table

Preview the exact permission change, then apply it:

python
from daita import Agent
 
async with await Agent.open("atlas") as agent:
    source = await agent.resolve_source("Support")
    preview = await agent.preview_source_permissions(
        source_id=source.id,
        read_mode="all",
        read_resource_ids=(),
        relational_write_scopes={"support.tickets": {
            "allowed_operations": ("update",),
            "allowed_update_columns": ("priority",),
            "max_rows": 25,
        }},
    )
    # Review the before/after state in `preview`, then apply it.
    await agent.apply_source_permissions(
        source_id=source.id,
        confirmation_fingerprint=preview.confirmation_fingerprint,
    )

In the app, use /source permissions and Edit table write access instead. Applying changes permissions only; no write runs. Check the table against the live database:

bash
daita relational-write-readiness atlas <source-id> support.tickets

#4. Ask for the change

bash
daita chat atlas
text
Set priority to 'high' for open tickets in Support that have been waiting more than 7 days.

The agent reads first, then proposes one UPDATE with data_write.

#5. Review the approval

Daita shows an approval card before anything is written:

  • the exact SQL and the target table;
  • the number of rows it will touch and up to five sample rows;
  • the columns that change, plus warnings such as a missing WHERE;
  • how far Daita can verify the result.

Choose Approve once or deny. Denying writes nothing. Approval applies to that exact statement and cannot be reused. If the rows changed since the preview, Daita refuses with write_state_changed and nothing is written. Scheduled routines and jobs ask the same way.

#6. Inspect the receipt

bash
daita effects list atlas
daita effects inspect atlas <receipt-id>

The receipt records the run and call, the expected row count and the outcome. succeeded means PostgreSQL acknowledged the commit and the touched rows matched the card. If an outcome is uncertain, do not retry. Compare the rows yourself, then record a decision with daita effects resolve.

#Turn writes off

In /source permissions, choose the table and select no operation. This does not revoke the PostgreSQL grant, so also revoke or rotate the role when needed.

#Next steps

  • Writes for the full rules, limits and recovery steps
  • PostgreSQL
  • Routines and Work
PreviousTry the Demo Database
NextTerminal and CLI

On this page

GoalPrerequisites1. Create a least-privileged role2. Attach the database3. Enable updates on one table4. Ask for the change5. Review the approval6. Inspect the receiptTurn writes offNext steps