MySQL with an AI Agent: Example Requests and Routines
· DoubleX
Quick answer
An AI agent can answer plain-language questions about your MySQL or MariaDB tables, run the query in read-only mode, and deliver results as a summary, spreadsheet, or report. With DoubleX IA OS, you can also schedule the same question to run every day or week.
Most teams that own a MySQL database get the same questions over and over: how many signups yesterday, which orders look stuck, what changed since last week. An AI agent turns those questions into read-only queries and returns the answer in a format people can use. This guide collects example requests and routines for technical, data, and research teams.
What kinds of questions can an AI agent answer about MySQL tables?#
An AI agent can answer any question that a read-only SELECT can answer: counts, sums, filters, comparisons between periods, lookups, and checks for odd data. An AI agent is an assistant that uses a model, instructions, and connected systems to do a task for you. In DoubleX IA OS, the MySQL connector reads the tables of a MySQL or MariaDB database directly, in read-only mode.
Typical question types:
- Counts and totals: records created per day, orders per status, active users per plan.
- Comparisons: this week against last week, this month against the same month last year.
- Data quality checks: rows with empty required fields, duplicate emails, orphaned foreign keys.
- Lookups: the full history of one customer, order, or device by ID.
- Schema questions: which tables hold a given kind of data and how they relate.
What example requests can a technical team use day to day?#
Start with specific requests that name the table, the period, and the format you want back. The more precise the request, the less the agent has to guess about your schema.
Copy and adapt these:
- "List the number of new rows in the
userstable for each of the last 14 days and flag any day that is more than twice the average." - "In the
orderstable, find orders with status 'pending' for more than 48 hours and show order ID, customer ID, and created date." - "Check the
customerstable for duplicate emails and give me the IDs of each duplicate group." - "Describe the tables that reference
customer_idand explain how they connect." - "Compare total
amountinpaymentsfor this month against last month, grouped by payment method."
How do I set up an agent to query MySQL?#
Create the agent, connect the database, set permissions, and then ask or schedule. The full connection walkthrough is in How to Connect MySQL to an AI Agent: Step-by-Step Guide.
- Create your account and run the diagnostic, or create an agent directly in the Agents screen by describing what it should do.
- Open Connectors and add the MySQL connector with your database details. Use a database user that only has read access, as an extra layer of safety.
- In the agent's settings, choose MySQL as one of the systems it can use and confirm that only read actions are available.
- Ask your first question in a task, and review the history to see each query the agent ran and the result.
- When the answer is what you want, turn the request into a routine (see the next section).
The Quickstart covers the first steps in the product.
How do I schedule a routine that queries the database every day or week?#
A routine is a trigger that makes the agent work on its own at a set time. You can run it every day at 8 a.m., every Monday, every hour, or once on a specific date. The routine runs with the permissions of the person who created it.
Good candidates for routines:
| Routine | When | What the agent does |
|---|---|---|
| Daily signup check | Every day, 8 a.m. | Counts new rows in users and compares with the previous days |
| Stuck orders report | Every hour | Lists orders in 'pending' beyond your threshold |
| Weekly data quality scan | Every Monday | Looks for duplicates and empty required fields |
| Monthly summary | First day of the month | Totals and comparisons by category for the previous month |
Write the routine request the way you would brief a colleague:
- "Every weekday at 8 a.m., count new rows in
usersfrom the last 24 hours, compare with the average of the previous 7 days, and summarize in three lines."
See the Triggers documentation if you want to create and manage routines through the API.
How do I deliver the result as a spreadsheet or report?#
Ask the agent to return the result as an artifact. An artifact is a file the agent delivers, such as a report, spreadsheet, presentation, or HTML page. Live artifacts, such as dashboards and small apps, update with the data.
Examples of what to ask for:
- "Run the stuck orders query and deliver it as a spreadsheet with one row per order."
- "Build a one-page report with last month's totals by payment method and a short written summary."
Artifacts appear in the Artifacts screen and can be shared with a person, a team, the whole company, or by link. This is useful for research and data teams that need to hand results to people who do not read SQL. More detail is in the Artifacts documentation.
How can I combine MySQL with Google Sheets or Slack?#
Connect more than one system to the same agent, and ask it to read from MySQL and write to the other. The Google Sheets connector reads and writes cells, appends rows, and creates spreadsheets. The Slack connector can read channels and send messages.
Example requests:
- "Query yesterday's new rows in
signupsand append one summary row to the 'Daily signups' sheet." - "Every Monday, query the weekly totals and post a short summary in the #data channel."
Because MySQL stays read-only while Sheets and Slack can change things, check what each connector is allowed to do in the agent's permissions. The agent asks for confirmation before sending or changing anything, and shows what it did step by step.
What limits does read-only mode impose?#
In read-only mode the agent can read and analyze, but it cannot insert, update, or delete rows, or change the schema. That protects your production data, and it also defines what the agent cannot do for you.
- It cannot fix data. It can find bad rows and list them, and your team makes the change.
- It cannot run migrations or alter tables.
- Complex or very large queries depend on your database's own performance, so ask for specific periods and columns.
Your content is not used to train models, each company has its own separate database, and connection credentials are encrypted with AES-256-GCM. Every task keeps a history of the request, each tool used, and the result.
Frequently asked questions#
Can an AI agent write to my MySQL database?#
No. The MySQL connector in DoubleX IA OS works in read-only mode. The agent can query tables, but it does not change data.
Does it work with MariaDB?#
Yes. The connector reads tables from a MySQL or MariaDB database directly.
Do I need to write SQL?#
No. You describe what you want in plain language and the agent builds and runs the query. You can review each step in the task history.
Can the agent run reports automatically?#
Yes. Create a routine that runs at a set time, such as daily or weekly, and ask for the output as a spreadsheet or report.
Can I trigger an agent from another system?#
Yes. An external system can start an agent through a webhook. See the Webhooks documentation for how it works.
Related guides
- How to Connect MySQL to an AI Agent: Step-by-Step GuideLearn how to connect a MySQL or MariaDB database to an AI agent with read-only access, per-agent permissions, and a first test query you can run today.
- How to Connect Gmail to an AI Agent, Step by StepLearn how to connect Gmail to an AI agent: add the connector, choose personal, team or company access, and set what the agent can read, draft or send.
- How to Automate Gmail Email Replies with AI DraftsLearn how to automate Gmail replies with AI: an agent reads incoming email, checks your company info, and writes drafts you review before anything is sent.