How AI Can Design Your SQLite Database and Perform Data Analysis

This guide demonstrates using the Tongyi Lingma AI agent to automatically design an SQLite database schema, generate SQL, insert sample data, and conduct data analysis with visual charts, covering all required installations, configurations, prompts, and code snippets.

Alibaba Cloud Native
Alibaba Cloud Native
Alibaba Cloud Native
How AI Can Design Your SQLite Database and Perform Data Analysis

Demo Purpose

The demonstration showcases how the Tongyi Lingma AI agent can design a database and carry out data analysis for a simple SQLite project.

Demo Preparation

Install the required tools:

SQLite3: brew install sqlite3 VS Code with the Tongyi Lingma plugin.

uvx (Python runner): pip install uvx Python 3.12+ (recommended via pipenv or poetry).

mcp-server-sqlite: uvx install mcp-server-sqlite npm: brew install npm Create a demo directory and an empty SQLite file:

mkdir <dir>
cd <dir>
touch demo.sqlite

Optionally install a VS Code SQLite extension to browse the database.

Configuration

Add the following JSON to the MCP configuration to enable the SQLite server and the AntV chart plugin (replace <your‑project‑path> and <your‑actual‑path>/demo.sqlite with your real paths):

{
  "mcpServers": {
    "git": {
      "command": "/opt/homebrew/bin/python3.12",
      "args": ["-m", "mcp_server_git", "--repository", "<your‑project‑path>"]
    },
    "mcp-server-sqlite": {
      "autoApprove": [],
      "disabled": false,
      "timeout": 60,
      "command": "mcp-server-sqlite",
      "args": ["--db-path", "<your‑actual‑path>/demo.sqlite"],
      "transportType": "stdio"
    },
    "mcp-server-chart": {
      "command": "npx",
      "args": ["-y", "@antv/mcp-server-chart"]
    }
  }
}

Make sure the database file path points to the file you created.

Demo Steps

1. Open the project folder in VS Code

Navigate to the folder containing demo.sqlite and open it with VS Code.

2. Start the Lingma agent

Use the qwen3-thing model in Agent mode and issue prompts such as: 查询下我 demo.sqlite 数据库有什么表 The agent replies with the list of tables.

3. Create a new table

Prompt the agent to design an order table for an e‑commerce shoe store:

我想创建一个订单表到我 demo.sqlite 数据库,用于电商卖鞋的订单表,字段请先根据你的理解提供

The agent generates the following SQL:

CREATE TABLE orders (
    order_id INTEGER PRIMARY KEY AUTOINCREMENT,
    customer_name TEXT NOT NULL,
    customer_email TEXT,
    shipping_address TEXT NOT NULL,
    product_id INTEGER NOT NULL,
    product_name TEXT NOT NULL,
    product_size TEXT,
    product_color TEXT,
    quantity INTEGER NOT NULL,
    total_price DECIMAL(10,2) NOT NULL,
    status TEXT DEFAULT 'pending',
    payment_method TEXT,
    payment_status TEXT DEFAULT 'unpaid',
    payment_date DATETIME,
    shipping_cost DECIMAL(10,2),
    shipping_status TEXT DEFAULT 'not_shipped',
    create_date DATETIME DEFAULT CURRENT_TIMESTAMP
);

4. Execute the SQL

Ask the agent to run the CREATE statement via MCP: 请通过 mcp 执行这些索引创建 The agent confirms execution (image of the result is shown).

5. Insert sample data

Prompt the agent to insert 100 sample rows: 请给数据库插入 100 条样例数据 The agent generates the INSERT statements and runs them (output shown in an image).

6. Perform data analysis

Ask the agent to classify orders by price range: 请按照订单价格区间做分类分析 The agent returns a textual analysis and then produces a bar chart using the mcp-server-chart plugin (chart image displayed).

Further prompts can request additional analyses, and the agent will respond with new visualizations.

Note: Because of model limitations, some operations may need to be run in multiple steps.

AIMCPData Analysisdatabase designSQLiteVS Code
Alibaba Cloud Native
Written by

Alibaba Cloud Native

We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.