[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-76432":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":14,"subscribersCount":14,"size":14,"stars1d":15,"stars7d":15,"stars30d":16,"stars90d":14,"forks30d":14,"starsTrendScore":17,"compositeScore":18,"rankGlobal":9,"rankLanguage":9,"license":9,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":19,"hasPages":19,"topics":21,"createdAt":9,"pushedAt":9,"updatedAt":22,"readmeContent":23,"aiSummary":24,"trendingCount":14,"starSnapshotCount":14,"syncStatus":25,"lastSyncTime":26,"discoverSource":27},76432,"sql_agent","Pains333\u002Fsql_agent","Pains333","Use an agent to help you manage your database",null,"Python",125,8,7,0,24,77,72,2.86,false,"main",[],"2026-06-12 02:03:41","\u003Cdiv align=\"center\">\n\n# 🤖 SQL Agent\n\n**An intelligent database assistant powered by LLM — operate databases with natural language.**\n\n[中文](#中文文档) · [English](#english-documentation)\n\n\u003C\u002Fdiv>\n\n---\n\n## 中文文档\n\n### 📖 简介\n\nSQL Agent 是一个基于大语言模型（LLM）的智能数据库助手。用户只需用自然语言描述需求，AI 会自动生成并执行 SQL 语句，支持建表、查询、数据导入等操作。\n\n### ✨ 功能特性\n\n- **🗣️ 自然语言转 SQL** — 用中文或英文描述需求，AI 自动生成 SQL 并执行\n- **📊 多数据库支持** — 支持 PostgreSQL、MySQL、Oracle\n- **🤖 多模型支持** — 支持本地 Ollama 模型或 OpenAI 兼容 API\n- **📎 附件数据导入** — 上传 Excel \u002F CSV \u002F Parquet \u002F JSON \u002F PKL 文件，智能匹配表结构并批量写入\n- **📝 自动元数据管理** — 自动维护 `skill.md` 文件，记录所有数据库和表的结构信息\n- **💬 多会话管理** — 支持创建、切换、删除多个对话\n- **🌐 中英文双语** — 界面完整支持中文和英文切换\n- **⚙️ 配置持久化** — 配置自动保存，重启后无需重新设置\n- **🎨 现代化 UI** — 基于 React + TypeScript 的简洁白色主题界面\n\n### 🏗️ 技术架构\n\n```\n┌─────────────────────────────────────────────┐\n│                  Frontend                    │\n│          React + TypeScript + Vite           │\n│                :5173                         │\n├─────────────────────────────────────────────┤\n│                  Backend                     │\n│            FastAPI + Uvicorn                 │\n│                :8000                         │\n├──────────┬──────────┬───────────────────────┤\n│  Agent   │ LLM Client│    DB Client         │\n│ (核心调度) │(Ollama\u002FAPI)│ (PostgreSQL\u002FMySQL)  │\n├──────────┴──────────┴───────────────────────┤\n│       Skill Manager  │  Data Importer       │\n│    (元数据管理)        │  (文件解析+导入)      │\n└─────────────────────────────────────────────┘\n```\n\n### 📁 项目结构\n\n```\nsql_agent\u002F\n├── server.py              # FastAPI 后端服务\n├── agent.py               # Agent 核心逻辑（调度 LLM + DB）\n├── llm_client.py          # LLM 客户端（Ollama \u002F OpenAI API）\n├── db_client.py           # 数据库客户端（多数据库支持）\n├── prompts.py             # LLM 提示词模板\n├── skill_manager.py       # skill.md 元数据管理\n├── file_parser.py         # 文件解析器（Excel\u002FCSV\u002FParquet\u002FJSON\u002FPKL）\n├── data_importer.py       # 数据导入器（列匹配 + 批量写入）\n├── conversation_store.py  # 对话持久化存储\n├── config.py              # 配置文件\n├── main.py                # CLI 模式入口\n├── requirements.txt       # Python 依赖\n├── skill.md               # 数据库元信息（自动维护）\n└── frontend\u002F              # React 前端\n    ├── src\u002F\n    │   ├── App.tsx         # 根组件\n    │   ├── api.ts          # API 客户端\n    │   ├── i18n.ts         # 国际化（中\u002F英）\n    │   ├── types.ts        # TypeScript 类型定义\n    │   └── components\u002F\n    │       ├── ChatArea.tsx       # 聊天区域（含附件上传）\n    │       ├── Sidebar.tsx        # 侧边栏（会话管理）\n    │       ├── SetupWizard.tsx    # 初始配置向导\n    │       ├── MessageBubble.tsx  # 消息气泡\n    │       └── ContextMenu.tsx    # 右键菜单\n    └── package.json\n```\n\n### 🚀 快速开始\n\n#### 环境要求\n\n- Python 3.10+\n- Node.js 18+\n- PostgreSQL \u002F MySQL \u002F Oracle（任选其一）\n- [Ollama](https:\u002F\u002Follama.ai\u002F)（如使用本地模型）\n\n#### 1. 克隆项目\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fyour-username\u002Fsql_agent.git\ncd sql_agent\n```\n\n#### 2. 安装后端依赖\n\n```bash\npip install -r requirements.txt\n```\n\n#### 3. 安装前端依赖\n\n```bash\ncd frontend\nnpm install\ncd ..\n```\n\n#### 4. 启动后端\n\n```bash\npython server.py\n```\n\n#### 5. 启动前端\n\n```bash\ncd frontend\nnpm run dev\n```\n\n#### 6. 打开浏览器\n\n访问 [http:\u002F\u002Flocalhost:5173](http:\u002F\u002Flocalhost:5173)，按照配置向导完成初始设置。\n\n### 📎 附件导入功能\n\n支持上传以下格式的文件并导入到数据库表：\n\n| 格式 | 扩展名 |\n|------|--------|\n| Excel | `.xlsx`, `.xls` |\n| CSV | `.csv` |\n| Parquet | `.parquet` |\n| JSON | `.json` |\n| Pickle | `.pkl` |\n\n**导入规则：**\n- 自增字段（如 `id`）自动跳过，由数据库生成\n- NOT NULL 字段必须在附件中存在对应列，否则报错\n- 可空字段如果附件中不存在，自动填充 `NULL`\n- 附件中多余的列（表中不存在的）自动忽略\n\n### ⚙️ 配置说明\n\n首次启动时，配置向导会引导你完成以下设置：\n\n| 配置项 | 说明 |\n|--------|------|\n| 语言 | 中文 \u002F English |\n| 模型来源 | 本地 Ollama 或 API |\n| 模型名称 | 如 `gemma4:31b`、`gpt-4o` 等 |\n| 数据库类型 | PostgreSQL \u002F MySQL \u002F Oracle |\n| 连接信息 | 主机、端口、用户名、密码 |\n\n配置保存在 `setup_config.json`，重启后自动加载。\n\n---\n\n## English Documentation\n\n### 📖 Introduction\n\nSQL Agent is an intelligent database assistant powered by Large Language Models (LLMs). Describe what you need in natural language, and AI will automatically generate and execute SQL statements — supporting table creation, queries, data imports, and more.\n\n### ✨ Features\n\n- **🗣️ Natural Language to SQL** — Describe your needs in plain language, AI generates and executes SQL\n- **📊 Multi-Database Support** — PostgreSQL, MySQL, Oracle\n- **🤖 Multi-Model Support** — Local Ollama models or OpenAI-compatible APIs\n- **📎 File Data Import** — Upload Excel \u002F CSV \u002F Parquet \u002F JSON \u002F PKL files with intelligent column matching\n- **📝 Auto Metadata Management** — Automatically maintains `skill.md` with all database and table structures\n- **💬 Multi-Session Chat** — Create, switch, and delete multiple conversations\n- **🌐 Bilingual UI** — Full Chinese and English interface support\n- **⚙️ Persistent Configuration** — Settings auto-saved, no reconfiguration needed after restart\n- **🎨 Modern UI** — Clean white theme built with React + TypeScript\n\n### 🏗️ Architecture\n\n```\n┌─────────────────────────────────────────────┐\n│                  Frontend                    │\n│          React + TypeScript + Vite           │\n│                :5173                         │\n├─────────────────────────────────────────────┤\n│                  Backend                     │\n│            FastAPI + Uvicorn                 │\n│                :8000                         │\n├──────────┬──────────┬───────────────────────┤\n│  Agent   │LLM Client│    DB Client          │\n│(Orchestr)│(Ollama\u002FAPI)│(PostgreSQL\u002FMySQL)    │\n├──────────┴──────────┴───────────────────────┤\n│      Skill Manager   │  Data Importer       │\n│   (Metadata Mgmt)    │ (File Parse+Import)  │\n└─────────────────────────────────────────────┘\n```\n\n### 📁 Project Structure\n\n```\nsql_agent\u002F\n├── server.py              # FastAPI backend server\n├── agent.py               # Core agent logic (orchestrates LLM + DB)\n├── llm_client.py          # LLM client (Ollama \u002F OpenAI API)\n├── db_client.py           # Database client (multi-DB support)\n├── prompts.py             # LLM prompt templates\n├── skill_manager.py       # skill.md metadata manager\n├── file_parser.py         # File parser (Excel\u002FCSV\u002FParquet\u002FJSON\u002FPKL)\n├── data_importer.py       # Data importer (column matching + batch insert)\n├── conversation_store.py  # Conversation persistence\n├── config.py              # Configuration\n├── main.py                # CLI mode entry point\n├── requirements.txt       # Python dependencies\n├── skill.md               # Database metadata (auto-maintained)\n└── frontend\u002F              # React frontend\n    ├── src\u002F\n    │   ├── App.tsx         # Root component\n    │   ├── api.ts          # API client\n    │   ├── i18n.ts         # Internationalization (zh\u002Fen)\n    │   ├── types.ts        # TypeScript type definitions\n    │   └── components\u002F\n    │       ├── ChatArea.tsx       # Chat area (with file upload)\n    │       ├── Sidebar.tsx        # Sidebar (session management)\n    │       ├── SetupWizard.tsx    # Setup wizard\n    │       ├── MessageBubble.tsx  # Message bubble\n    │       └── ContextMenu.tsx    # Context menu\n    └── package.json\n```\n\n### 🚀 Quick Start\n\n#### Prerequisites\n\n- Python 3.10+\n- Node.js 18+\n- PostgreSQL \u002F MySQL \u002F Oracle (any one)\n- [Ollama](https:\u002F\u002Follama.ai\u002F) (if using local models)\n\n#### 1. Clone the repository\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fyour-username\u002Fsql_agent.git\ncd sql_agent\n```\n\n#### 2. Install backend dependencies\n\n```bash\npip install -r requirements.txt\n```\n\n#### 3. Install frontend dependencies\n\n```bash\ncd frontend\nnpm install\ncd ..\n```\n\n#### 4. Start the backend\n\n```bash\npython server.py\n```\n\n#### 5. Start the frontend\n\n```bash\ncd frontend\nnpm run dev\n```\n\n#### 6. Open in browser\n\nVisit [http:\u002F\u002Flocalhost:5173](http:\u002F\u002Flocalhost:5173) and follow the setup wizard.\n\n### 📎 File Import\n\nSupported file formats for data import:\n\n| Format | Extension |\n|--------|-----------|\n| Excel | `.xlsx`, `.xls` |\n| CSV | `.csv` |\n| Parquet | `.parquet` |\n| JSON | `.json` |\n| Pickle | `.pkl` |\n\n**Import Rules:**\n- Auto-increment fields (e.g., `id`) are skipped — generated by the database\n- NOT NULL fields must have matching columns in the file, otherwise an error is raised\n- Nullable fields missing from the file are filled with `NULL`\n- Extra columns in the file (not in the table) are silently ignored\n\n### ⚙️ Configuration\n\nThe setup wizard guides you through:\n\n| Setting | Description |\n|---------|-------------|\n| Language | Chinese \u002F English |\n| Model Source | Local Ollama or API |\n| Model Name | e.g., `gemma4:31b`, `gpt-4o` |\n| Database Type | PostgreSQL \u002F MySQL \u002F Oracle |\n| Connection | Host, port, username, password |\n\nSettings are saved to `setup_config.json` and auto-loaded on restart.\n\n---\n\n\u003Cdiv align=\"center\">\n\n### 📄 License\n\nMIT License\n\n\u003C\u002Fdiv>\n","SQL Agent 是一个基于大语言模型的智能数据库助手，能够通过自然语言处理用户需求并自动生成和执行 SQL 语句。其核心功能包括自然语言转 SQL、多数据库支持（如 PostgreSQL、MySQL 和 Oracle）、多模型支持（本地 Ollama 模型或 OpenAI 兼容 API），以及附件数据导入（支持多种文件格式）。此外，它还具备自动元数据管理、多会话管理和中英文双语界面等特性。技术上，该项目采用 React + TypeScript 构建现代化 UI，并使用 FastAPI 作为后端服务框架。SQL Agent 适用于需要简化数据库操作流程、提高工作效率的各种场景，特别适合对数据库操作不熟悉但又频繁需要进行相关工作的用户。",2,"2026-06-11 03:55:03","CREATED_QUERY"]