Ask an AI to Update Your Database - With Your Permission
datasette-agent now lets you modify data using plain English, but only after you say OK
What it is
datasette-agent is a tool that lets an AI assistant read and write to a Datasette database using plain language commands. Version 0.3a0 adds a new tool called 'execute_write_sql' that lets the AI make changes to your data - but it must ask for your approval first, and it takes user permissions into account when doing so.
Why it matters
If you manage data in Datasette, you no longer have to write database commands by hand - you can just describe what you want in plain English, like 'add a note about X' or 'create a notes table.' The approval step means the AI can't change your data without you seeing and confirming what it's about to do, which keeps things safe. This is a practical step toward using AI as a real assistant for data tasks, not just a demo.
How to use it
- 1Step 1: Open datasette-agent in chat mode by running a command like: datasette agent chat content.db (optionally specifying a model with -m).
- 2Step 2: Type a plain-English request, such as 'create a notes table' or 'add a note about X'.
- 3Step 3: The agent will show you what it plans to write to the database and ask for your approval before doing anything. Note that execute_write_sql takes user permissions into account when executing writes.
- 4Step 4: Review what it proposes, then approve or decline.
- 5Step 5 (optional): If you want to skip approval prompts, you can use --yes to approve all ask user questions automatically, --unsafe for auto-approving all actions, or --root to run as root. These options skip some or all safety checks, so use them carefully.
Example
A user runs: datasette agent chat content.db --unsafe and then types 'add a pelican sighting to the pelican_sightings table.' Because --unsafe mode is enabled, the agent proceeds without pausing to ask for approval.
Practice it
Try this in ChatGPT or Claude to practice giving clear, plain-English data instructions: 'I have a table called pelican_sightings with columns: date, location, count. Write me three example rows I could add, and show me what a plain-English prompt to add each one might look like.'