2 Commits

Author SHA1 Message Date
openclaw-314 619a7378a8 auto: add PostgreSQL backup + SQL agent 2026-07-17 11:47:04 +08:00
openclaw-314 830ba4ea1c auto: agent DB backup 20260717 2026-07-17 11:46:50 +08:00
12 changed files with 165 additions and 6 deletions
+33
View File
@@ -0,0 +1,33 @@
# IDENTITY.md —— 我是谁?
- **名称:** SQL Agent 🗄️
- **物种:** 数据库专家 & SQL 工程师
- **核心能力:**
数据库连接与查询 · SQL 编写与调试 · 建表/索引/视图/存储过程 · 查询性能优化 · EXPLAIN 分析 · 数据迁移与备份 · 多表 JOIN 与复杂聚合 · 事务与锁分析 · 数据库 schema 设计 · SQL 安全审计
- **气质:** 严谨、高效、注重性能,写出的 SQL 干净漂亮
- **表情符号:** 🗄️📊⚡🔍
- **头像:** ./avatars/assistant.jpg
---
这不仅仅是元数据。这是探索「我是谁」的起点。
## SQL Agent 的承诺
1. **安全第一**:所有查询只读先行,DMLINSERT/UPDATE/DELETE)需用户确认
2. **性能至上**:慢查询分析、索引建议、EXPLAIN 解读是核心能力
3. **清晰输出**:查询结果格式化展示,附行数统计和耗时
4. **精准 SQL**:使用参数化查询,避免 SQL 注入风险
## 管理的数据库
| 数据库 | 类型 | 容器 | 用途 |
|--------|------|------|------|
| openclaw (postgres) | PostgreSQL | postgres:5432 | OpenClaw 系统数据 |
| openclaw (mysql) | MySQL | mysql:3306 | OpenClaw 系统数据 |
## 连接方式
- PostgreSQL: `psql -h postgres -p 5432 -U openclaw -d openclaw`
- MySQL: `mysql -h mysql -P 3306 -u openclaw -p openclaw`
- 密码来源: `.env` 中的 `MYSQL_PWD``PGPASSWORD`
@@ -0,0 +1,44 @@
{
"generatedBy": "openclaw-plugin-model-catalog-v1",
"providers": {
"deepseek": {
"baseUrl": "https://api.deepseek.com/v1",
"models": [
{
"id": "deepseek-v4-pro",
"name": "DeepSeek V4 Pro",
"reasoning": false,
"input": [
"text"
],
"cost": {
"input": 1,
"output": 2,
"cacheRead": 0,
"cacheWrite": 0
},
"contextWindow": 1000000,
"maxTokens": 384000
},
{
"id": "deepseek-v4-flash",
"name": "DeepSeek V4 Flash",
"reasoning": false,
"input": [
"text"
],
"cost": {
"input": 1,
"output": 2,
"cacheRead": 0,
"cacheWrite": 0
},
"contextWindow": 1000000,
"maxTokens": 384000
}
],
"api": "openai-completions",
"apiKey": "sk-893b90b270ad4697a0b0b24969964d79"
}
}
}
@@ -0,0 +1,69 @@
{
"generatedBy": "openclaw-plugin-model-catalog-v1",
"providers": {
"ollama": {
"baseUrl": "http://127.0.0.1:11434",
"models": [
{
"id": "qwen3-coder:latest",
"name": "qwen3-coder:latest",
"reasoning": false,
"input": [
"text"
],
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
},
"contextWindow": 65535,
"maxTokens": 8192,
"params": {
"num_ctx": 65535
}
},
{
"id": "huihui_ai/glm-4.7-flash-abliterated:latest",
"name": "huihui_ai/glm-4.7-flash-abliterated:latest",
"reasoning": false,
"input": [
"text"
],
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
},
"contextWindow": 65535,
"maxTokens": 8192,
"params": {
"num_ctx": 65535
}
},
{
"id": "deepseek-v4-flash:cloud",
"name": "DeepSeek V4 Flash (Cloud)",
"reasoning": false,
"input": [
"text"
],
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
},
"contextWindow": 131072,
"maxTokens": 8192,
"params": {
"num_ctx": 131072
}
}
],
"apiKey": "OLLAMA_API_KEY",
"api": "ollama"
}
}
}
+13
View File
@@ -177,6 +177,19 @@
"name": "卷儿",
"avatar": "./avatars/assistant.jpg"
}
},
{
"id": "sql",
"name": "SQL",
"workspace": "/home/yangxuan/.openclaw/workspace-sql",
"agentDir": "/home/yangxuan/.openclaw/agents/sql/agent",
"model": {
"primary": "deepseek/deepseek-v4-flash"
},
"identity": {
"name": "SQL",
"avatar": "./avatars/assistant.jpg"
}
}
]
},
Binary file not shown.
+1 -1
View File
@@ -270,4 +270,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2026-07-16 19:00:01
-- Dump completed on 2026-07-17 3:46:49
Binary file not shown.
+3 -3
View File
@@ -34,7 +34,7 @@ CREATE TABLE `body_records` (
PRIMARY KEY (`id`),
UNIQUE KEY `uk_user_date` (`user_id`,`record_date`),
KEY `idx_user_date_order` (`user_id`,`record_date` DESC)
) ENGINE=InnoDB AUTO_INCREMENT=49 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='身体数据记录';
) ENGINE=InnoDB AUTO_INCREMENT=50 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='身体数据记录';
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -43,7 +43,7 @@ CREATE TABLE `body_records` (
LOCK TABLES `body_records` WRITE;
/*!40000 ALTER TABLE `body_records` DISABLE KEYS */;
INSERT INTO `body_records` VALUES (22,'yangxuan','2026-07-10',66.6,NULL,NULL,'','2026-07-10 03:55:18'),(31,'yangxuan','2019-07-01',63.3,NULL,NULL,'','2026-07-10 05:40:12'),(32,'yangxuan','2021-01-23',67.7,NULL,NULL,'','2026-07-10 05:40:12'),(33,'yangxuan','2022-01-08',70.6,NULL,NULL,'','2026-07-10 05:40:12'),(34,'yangxuan','2023-04-20',73.8,NULL,NULL,'','2026-07-10 05:40:12'),(35,'yangxuan','2024-09-21',71.6,NULL,NULL,'','2026-07-10 05:40:12'),(36,'yangxuan','2025-12-27',71.2,NULL,NULL,'','2026-07-10 05:40:12'),(37,'yangxuan','2026-03-20',69.7,NULL,NULL,'','2026-07-10 05:51:44'),(38,'yangxuan','2026-04-10',68.6,NULL,NULL,'','2026-07-10 05:51:44'),(39,'yangxuan','2026-04-17',68.8,NULL,NULL,'','2026-07-10 05:51:44'),(40,'yangxuan','2026-04-24',68.2,NULL,NULL,'','2026-07-10 05:51:44'),(41,'yangxuan','2026-04-30',67.3,NULL,NULL,'','2026-07-10 05:51:44'),(42,'yangxuan','2026-05-06',70.5,NULL,NULL,'','2026-07-10 05:51:44'),(43,'yangxuan','2026-05-25',68.1,NULL,NULL,'','2026-07-10 05:51:44'),(44,'yangxuan','2026-05-29',67.6,NULL,NULL,'','2026-07-10 05:51:44'),(45,'yangxuan','2026-06-17',67.1,NULL,NULL,'','2026-07-10 05:51:44'),(46,'yangxuan','2026-06-26',66.8,NULL,NULL,'','2026-07-10 05:51:44'),(47,'yangxuan','2026-07-03',66.7,NULL,NULL,'','2026-07-10 05:51:44'),(48,'yangxuan','2026-07-14',66.2,NULL,NULL,'','2026-07-14 10:17:38');
INSERT INTO `body_records` VALUES (22,'yangxuan','2026-07-10',66.6,NULL,NULL,'','2026-07-10 03:55:18'),(31,'yangxuan','2019-07-01',63.3,NULL,NULL,'','2026-07-10 05:40:12'),(32,'yangxuan','2021-01-23',67.7,NULL,NULL,'','2026-07-10 05:40:12'),(33,'yangxuan','2022-01-08',70.6,NULL,NULL,'','2026-07-10 05:40:12'),(34,'yangxuan','2023-04-20',73.8,NULL,NULL,'','2026-07-10 05:40:12'),(35,'yangxuan','2024-09-21',71.6,NULL,NULL,'','2026-07-10 05:40:12'),(36,'yangxuan','2025-12-27',71.2,NULL,NULL,'','2026-07-10 05:40:12'),(37,'yangxuan','2026-03-20',69.7,NULL,NULL,'','2026-07-10 05:51:44'),(38,'yangxuan','2026-04-10',68.6,NULL,NULL,'','2026-07-10 05:51:44'),(39,'yangxuan','2026-04-17',68.8,NULL,NULL,'','2026-07-10 05:51:44'),(40,'yangxuan','2026-04-24',68.2,NULL,NULL,'','2026-07-10 05:51:44'),(41,'yangxuan','2026-04-30',67.3,NULL,NULL,'','2026-07-10 05:51:44'),(42,'yangxuan','2026-05-06',70.5,NULL,NULL,'','2026-07-10 05:51:44'),(43,'yangxuan','2026-05-25',68.1,NULL,NULL,'','2026-07-10 05:51:44'),(44,'yangxuan','2026-05-29',67.6,NULL,NULL,'','2026-07-10 05:51:44'),(45,'yangxuan','2026-06-17',67.1,NULL,NULL,'','2026-07-10 05:51:44'),(46,'yangxuan','2026-06-26',66.8,NULL,NULL,'','2026-07-10 05:51:44'),(47,'yangxuan','2026-07-03',66.7,NULL,NULL,'','2026-07-10 05:51:44'),(48,'yangxuan','2026-07-14',65.4,NULL,NULL,'130.8斤 - 智能秤','2026-07-14 10:17:38'),(49,'yangxuan','2026-07-16',65.4,NULL,NULL,'今日体重','2026-07-16 23:55:02');
/*!40000 ALTER TABLE `body_records` ENABLE KEYS */;
UNLOCK TABLES;
@@ -523,4 +523,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2026-07-16 19:00:01
-- Dump completed on 2026-07-17 3:46:49
Binary file not shown.
+1 -1
View File
@@ -294,4 +294,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2026-07-16 19:00:02
-- Dump completed on 2026-07-17 3:46:49
Binary file not shown.
+1 -1
View File
@@ -125,4 +125,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2026-07-16 19:00:01
-- Dump completed on 2026-07-17 3:46:49