sql-assistant 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sql_assistant/__init__.py +3 -0
- sql_assistant/api/__init__.py +1 -0
- sql_assistant/api/backup.py +116 -0
- sql_assistant/api/config.py +183 -0
- sql_assistant/api/conversation.py +71 -0
- sql_assistant/api/dependencies.py +22 -0
- sql_assistant/api/history.py +61 -0
- sql_assistant/api/models.py +221 -0
- sql_assistant/api/query.py +275 -0
- sql_assistant/api/routes.py +19 -0
- sql_assistant/api/schema.py +21 -0
- sql_assistant/config.py +144 -0
- sql_assistant/database/__init__.py +1 -0
- sql_assistant/database/backup.py +568 -0
- sql_assistant/database/connectors/__init__.py +1 -0
- sql_assistant/database/connectors/base.py +185 -0
- sql_assistant/database/connectors/exceptions.py +88 -0
- sql_assistant/database/connectors/mongodb.py +194 -0
- sql_assistant/database/connectors/mysql.py +110 -0
- sql_assistant/database/connectors/postgresql.py +133 -0
- sql_assistant/database/connectors/redis.py +132 -0
- sql_assistant/database/connectors/sqlserver.py +140 -0
- sql_assistant/database/history.py +290 -0
- sql_assistant/database/manager.py +178 -0
- sql_assistant/database/security.py +230 -0
- sql_assistant/llm/__init__.py +1 -0
- sql_assistant/llm/base.py +28 -0
- sql_assistant/llm/exceptions.py +96 -0
- sql_assistant/llm/manager.py +82 -0
- sql_assistant/llm/prompts.py +29 -0
- sql_assistant/llm/providers/__init__.py +1 -0
- sql_assistant/llm/providers/claude.py +132 -0
- sql_assistant/llm/providers/gemini.py +127 -0
- sql_assistant/llm/providers/openai_compatible.py +103 -0
- sql_assistant/llm/retry.py +88 -0
- sql_assistant/main.py +94 -0
- sql_assistant/settings.py +219 -0
- sql_assistant/web/__init__.py +1 -0
- sql_assistant/web/static/css/base.css +25 -0
- sql_assistant/web/static/css/components/backup.css +146 -0
- sql_assistant/web/static/css/components/chat.css +465 -0
- sql_assistant/web/static/css/components/modal.css +143 -0
- sql_assistant/web/static/css/components/settings.css +358 -0
- sql_assistant/web/static/css/components/sidebar.css +235 -0
- sql_assistant/web/static/css/components/toast.css +30 -0
- sql_assistant/web/static/css/style.css +10 -0
- sql_assistant/web/static/css/theme.css +200 -0
- sql_assistant/web/static/js/api.js +38 -0
- sql_assistant/web/static/js/app.js +161 -0
- sql_assistant/web/static/js/backup.js +216 -0
- sql_assistant/web/static/js/chat.js +238 -0
- sql_assistant/web/static/js/color-theme-manager.js +121 -0
- sql_assistant/web/static/js/confirm.js +95 -0
- sql_assistant/web/static/js/conversations.js +182 -0
- sql_assistant/web/static/js/settings.js +425 -0
- sql_assistant/web/static/js/state.js +43 -0
- sql_assistant/web/static/js/theme-manager.js +64 -0
- sql_assistant/web/static/js/ui.js +53 -0
- sql_assistant/web/templates/index.html +373 -0
- sql_assistant-1.0.0.dist-info/METADATA +24 -0
- sql_assistant-1.0.0.dist-info/RECORD +64 -0
- sql_assistant-1.0.0.dist-info/WHEEL +4 -0
- sql_assistant-1.0.0.dist-info/entry_points.txt +2 -0
- sql_assistant-1.0.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>SQL 智能助手</title>
|
|
7
|
+
<link rel="stylesheet" href="/static/css/theme.css">
|
|
8
|
+
<link rel="stylesheet" href="/static/css/style.css">
|
|
9
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
|
|
10
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/sql.min.js"></script>
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<div class="app-container">
|
|
14
|
+
<!-- 侧边栏 -->
|
|
15
|
+
<aside class="sidebar" id="sidebar">
|
|
16
|
+
<div class="sidebar-header">
|
|
17
|
+
<h1 class="app-logo">🔍 SQL 助手</h1>
|
|
18
|
+
<div class="header-actions">
|
|
19
|
+
<button class="btn-icon" id="btn-toggle-theme" title="切换主题">
|
|
20
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/></svg>
|
|
21
|
+
</button>
|
|
22
|
+
<button class="btn-icon" id="btn-settings" title="设置">
|
|
23
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>
|
|
24
|
+
</button>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<!-- 当前连接状态 -->
|
|
29
|
+
<div class="connection-status" id="connection-status">
|
|
30
|
+
<span class="status-dot offline"></span>
|
|
31
|
+
<span class="status-text">未配置连接</span>
|
|
32
|
+
<button class="btn-icon btn-schema-refresh" id="btn-refresh-schema" title="刷新 Schema" style="display:none; margin-left: auto; padding: 4px 6px;">
|
|
33
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="23 4 23 10 17 10"/><polyline points="1 20 1 14 7 14"/><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/></svg>
|
|
34
|
+
</button>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<!-- 对话列表 -->
|
|
38
|
+
<div class="history-section">
|
|
39
|
+
<div class="history-header">
|
|
40
|
+
<h3>对话列表</h3>
|
|
41
|
+
<button class="btn-text btn-new-chat" id="btn-new-chat">+ 新对话</button>
|
|
42
|
+
</div>
|
|
43
|
+
<div class="history-list" id="history-list">
|
|
44
|
+
<div class="history-empty">暂无对话</div>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
</aside>
|
|
48
|
+
|
|
49
|
+
<!-- 主内容区 -->
|
|
50
|
+
<main class="main-content">
|
|
51
|
+
<div class="chat-container">
|
|
52
|
+
<!-- 消息区域 -->
|
|
53
|
+
<div class="chat-messages" id="chat-messages">
|
|
54
|
+
<div class="welcome-message">
|
|
55
|
+
<div class="welcome-icon">💬</div>
|
|
56
|
+
<h2>SQL 智能助手</h2>
|
|
57
|
+
<p>用自然语言描述你的查询需求,AI 会帮你生成 SQL 并执行</p>
|
|
58
|
+
<p class="welcome-hint">请先在设置中配置 LLM API Key 和数据库连接</p>
|
|
59
|
+
<div class="welcome-examples">
|
|
60
|
+
<span class="example-tag" data-question="查询所有用户信息">查询所有用户信息</span>
|
|
61
|
+
<span class="example-tag" data-question="统计每个部门的员工数量">统计每个部门的员工数量</span>
|
|
62
|
+
<span class="example-tag" data-question="添加一条商品记录,名称 iPhone 15,价格 6999">添加商品记录</span>
|
|
63
|
+
<span class="example-tag" data-question="查询最近7天的订单">查询最近7天订单</span>
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
<!-- 输入区域 -->
|
|
69
|
+
<div class="chat-input-container">
|
|
70
|
+
<form id="query-form" class="chat-input-form">
|
|
71
|
+
<textarea
|
|
72
|
+
id="query-input"
|
|
73
|
+
placeholder="输入自然语言查询,例如:查询所有用户的姓名和邮箱"
|
|
74
|
+
rows="1"
|
|
75
|
+
autocomplete="off"
|
|
76
|
+
></textarea>
|
|
77
|
+
<button type="submit" class="btn-send" id="btn-send" disabled>
|
|
78
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/></svg>
|
|
79
|
+
</button>
|
|
80
|
+
</form>
|
|
81
|
+
<p class="input-hint">按 Enter 发送,Shift+Enter 换行</p>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
</main>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<!-- 设置弹窗 -->
|
|
88
|
+
<div class="modal-overlay" id="settings-modal">
|
|
89
|
+
<div class="modal-container">
|
|
90
|
+
<div class="modal-header">
|
|
91
|
+
<h2>⚙️ 设置</h2>
|
|
92
|
+
<button class="btn-icon" id="btn-close-modal">
|
|
93
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
|
|
94
|
+
</button>
|
|
95
|
+
</div>
|
|
96
|
+
<div class="modal-body">
|
|
97
|
+
<!-- Tab 切换 -->
|
|
98
|
+
<div class="settings-tabs">
|
|
99
|
+
<button class="tab-btn active" data-tab="llm">🤖 LLM 配置</button>
|
|
100
|
+
<button class="tab-btn" data-tab="database">🗄️ 数据库配置</button>
|
|
101
|
+
<button class="tab-btn" data-tab="backup">📦 数据库备份</button>
|
|
102
|
+
<button class="tab-btn" data-tab="about">ℹ️ 关于</button>
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
<!-- LLM 配置面板 -->
|
|
106
|
+
<div class="tab-panel active" id="tab-llm">
|
|
107
|
+
<div class="config-list" id="llm-config-list"></div>
|
|
108
|
+
|
|
109
|
+
<button class="btn-add" id="btn-add-llm">+ 添加 LLM 提供商</button>
|
|
110
|
+
|
|
111
|
+
<!-- LLM 编辑表单 -->
|
|
112
|
+
<div class="config-form" id="llm-form" style="display:none;">
|
|
113
|
+
<h4 id="llm-form-title">添加 LLM 提供商</h4>
|
|
114
|
+
<div class="form-group">
|
|
115
|
+
<label>配置名称</label>
|
|
116
|
+
<input type="text" id="llm-name" placeholder="如:我的DeepSeek" required>
|
|
117
|
+
</div>
|
|
118
|
+
<div class="form-group">
|
|
119
|
+
<label>提供商</label>
|
|
120
|
+
<select id="llm-provider">
|
|
121
|
+
<option value="deepseek">DeepSeek</option>
|
|
122
|
+
<option value="doubao">豆包 (Doubao)</option>
|
|
123
|
+
<option value="kimi">Kimi (Moonshot)</option>
|
|
124
|
+
<option value="qwen">通义千问 (Qwen)</option>
|
|
125
|
+
<option value="openai">OpenAI</option>
|
|
126
|
+
<option value="gemini">Google Gemini</option>
|
|
127
|
+
<option value="claude">Anthropic Claude</option>
|
|
128
|
+
<option value="glm">智谱 GLM</option>
|
|
129
|
+
<option value="minimax">MiniMax</option>
|
|
130
|
+
<option value="siliconflow">硅基流动 (SiliconFlow)</option>
|
|
131
|
+
<option value="openrouter">OpenRouter</option>
|
|
132
|
+
<option value="grok">Grok (xAI)</option>
|
|
133
|
+
<option value="tencent">腾讯混元</option>
|
|
134
|
+
<option value="mimo">小米 MiMo</option>
|
|
135
|
+
<option value="ollama">Ollama (本地)</option>
|
|
136
|
+
</select>
|
|
137
|
+
</div>
|
|
138
|
+
<div class="form-group">
|
|
139
|
+
<label>API Key</label>
|
|
140
|
+
<input type="password" id="llm-api-key" placeholder="sk-..." required>
|
|
141
|
+
</div>
|
|
142
|
+
<div class="form-group">
|
|
143
|
+
<label>Base URL(可选,留空使用默认)</label>
|
|
144
|
+
<input type="text" id="llm-base-url" placeholder="自动填充默认地址">
|
|
145
|
+
</div>
|
|
146
|
+
<div class="form-group">
|
|
147
|
+
<label>模型名称</label>
|
|
148
|
+
<select id="llm-model">
|
|
149
|
+
<option value="">选择模型...</option>
|
|
150
|
+
</select>
|
|
151
|
+
</div>
|
|
152
|
+
<div class="form-actions">
|
|
153
|
+
<button class="btn-primary" id="btn-save-llm">保存</button>
|
|
154
|
+
<button class="btn-primary btn-test" id="btn-test-llm">测试连接</button>
|
|
155
|
+
<button class="btn-text" id="btn-cancel-llm">取消</button>
|
|
156
|
+
</div>
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
|
|
160
|
+
<!-- 数据库配置面板 -->
|
|
161
|
+
<div class="tab-panel" id="tab-database">
|
|
162
|
+
<div class="config-list" id="db-config-list"></div>
|
|
163
|
+
<button class="btn-add" id="btn-add-db">+ 添加数据库连接</button>
|
|
164
|
+
|
|
165
|
+
<!-- DB 编辑表单 -->
|
|
166
|
+
<div class="config-form" id="db-form" style="display:none;">
|
|
167
|
+
<h4 id="db-form-title">添加数据库连接</h4>
|
|
168
|
+
<div class="form-group">
|
|
169
|
+
<label>连接名称</label>
|
|
170
|
+
<input type="text" id="db-name" placeholder="如:生产MySQL" required>
|
|
171
|
+
</div>
|
|
172
|
+
<div class="form-group">
|
|
173
|
+
<label>数据库类型</label>
|
|
174
|
+
<select id="db-type">
|
|
175
|
+
<option value="mysql">MySQL</option>
|
|
176
|
+
<option value="postgresql">PostgreSQL</option>
|
|
177
|
+
<option value="sqlserver">SQL Server</option>
|
|
178
|
+
<option value="redis">Redis</option>
|
|
179
|
+
<option value="mongodb">MongoDB</option>
|
|
180
|
+
</select>
|
|
181
|
+
</div>
|
|
182
|
+
<div class="form-group">
|
|
183
|
+
<label>主机地址</label>
|
|
184
|
+
<input type="text" id="db-host" placeholder="localhost" required>
|
|
185
|
+
</div>
|
|
186
|
+
<div class="form-group">
|
|
187
|
+
<label>端口(留空使用默认)</label>
|
|
188
|
+
<input type="number" id="db-port" placeholder="自动填充">
|
|
189
|
+
</div>
|
|
190
|
+
<div class="form-group">
|
|
191
|
+
<label>用户名</label>
|
|
192
|
+
<input type="text" id="db-user" placeholder="root">
|
|
193
|
+
</div>
|
|
194
|
+
<div class="form-group">
|
|
195
|
+
<label>密码</label>
|
|
196
|
+
<input type="password" id="db-password" placeholder="数据库密码">
|
|
197
|
+
</div>
|
|
198
|
+
<div class="form-group">
|
|
199
|
+
<label>数据库名</label>
|
|
200
|
+
<input type="text" id="db-database" placeholder="数据库名称" required>
|
|
201
|
+
</div>
|
|
202
|
+
<div class="form-actions">
|
|
203
|
+
<button class="btn-primary" id="btn-save-db">保存</button>
|
|
204
|
+
<button class="btn-primary btn-test" id="btn-test-db">测试连接</button>
|
|
205
|
+
<button class="btn-text" id="btn-cancel-db">取消</button>
|
|
206
|
+
</div>
|
|
207
|
+
</div>
|
|
208
|
+
</div>
|
|
209
|
+
|
|
210
|
+
<!-- 备份面板 -->
|
|
211
|
+
<div class="tab-panel" id="tab-backup">
|
|
212
|
+
<div class="backup-section">
|
|
213
|
+
<div class="backup-form">
|
|
214
|
+
<h4>创建备份</h4>
|
|
215
|
+
<div class="form-group">
|
|
216
|
+
<label>备份类型</label>
|
|
217
|
+
<select id="backup-type">
|
|
218
|
+
<option value="full">全量备份</option>
|
|
219
|
+
<option value="incremental">增量备份</option>
|
|
220
|
+
</select>
|
|
221
|
+
</div>
|
|
222
|
+
<div class="form-group">
|
|
223
|
+
<label>备份范围</label>
|
|
224
|
+
<select id="backup-scope" onchange="toggleTableSelection()">
|
|
225
|
+
<option value="all">所有表</option>
|
|
226
|
+
<option value="selected">指定表</option>
|
|
227
|
+
</select>
|
|
228
|
+
</div>
|
|
229
|
+
<div class="form-group" id="table-selection-group" style="display:none;">
|
|
230
|
+
<label>选择表(可多选)</label>
|
|
231
|
+
<select id="backup-tables" multiple size="6"></select>
|
|
232
|
+
</div>
|
|
233
|
+
<div class="form-group">
|
|
234
|
+
<label>
|
|
235
|
+
<input type="checkbox" id="backup-include-schema" checked> 包含表结构
|
|
236
|
+
</label>
|
|
237
|
+
</div>
|
|
238
|
+
<div class="form-group">
|
|
239
|
+
<label>
|
|
240
|
+
<input type="checkbox" id="backup-include-data" checked> 包含数据
|
|
241
|
+
</label>
|
|
242
|
+
</div>
|
|
243
|
+
<div class="form-actions">
|
|
244
|
+
<button class="btn-primary" id="btn-create-backup">开始备份</button>
|
|
245
|
+
</div>
|
|
246
|
+
</div>
|
|
247
|
+
|
|
248
|
+
<div class="backup-list-section">
|
|
249
|
+
<h4>备份列表</h4>
|
|
250
|
+
<div class="backup-list" id="backup-list">
|
|
251
|
+
<div class="empty-state">暂无备份记录</div>
|
|
252
|
+
</div>
|
|
253
|
+
</div>
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
256
|
+
|
|
257
|
+
<!-- 恢复备份模态框 -->
|
|
258
|
+
<div class="modal-overlay" id="restore-modal">
|
|
259
|
+
<div class="modal-container" style="width: 480px;">
|
|
260
|
+
<div class="modal-header">
|
|
261
|
+
<h2>📥 恢复备份</h2>
|
|
262
|
+
<button class="btn-icon" onclick="closeRestoreModal()">
|
|
263
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
|
|
264
|
+
</button>
|
|
265
|
+
</div>
|
|
266
|
+
<div class="modal-body">
|
|
267
|
+
<div id="restore-backup-info" style="margin-bottom: 16px; padding: 12px; background: var(--bg-tertiary); border-radius: var(--radius-sm);"></div>
|
|
268
|
+
<div class="form-group">
|
|
269
|
+
<label>
|
|
270
|
+
<input type="checkbox" id="restore-schema"> 重建表结构(会删除现有表,谨慎使用)
|
|
271
|
+
</label>
|
|
272
|
+
</div>
|
|
273
|
+
<div class="form-group">
|
|
274
|
+
<label>
|
|
275
|
+
<input type="checkbox" id="restore-data" checked> 恢复数据
|
|
276
|
+
</label>
|
|
277
|
+
</div>
|
|
278
|
+
<div class="form-actions">
|
|
279
|
+
<button class="btn-primary" id="btn-confirm-restore">确认恢复</button>
|
|
280
|
+
<button class="btn-text" onclick="closeRestoreModal()">取消</button>
|
|
281
|
+
</div>
|
|
282
|
+
<div id="restore-warning" style="margin-top: 16px; padding: 12px; background: rgba(248,81,73,0.1); border: 1px solid rgba(248,81,73,0.3); border-radius: var(--radius-sm); color: var(--danger); font-size: 13px; display: none;">
|
|
283
|
+
⚠️ 警告:恢复操作会覆盖现有数据,建议先备份当前数据!
|
|
284
|
+
</div>
|
|
285
|
+
</div>
|
|
286
|
+
</div>
|
|
287
|
+
</div>
|
|
288
|
+
|
|
289
|
+
<!-- 关于面板 -->
|
|
290
|
+
<div class="tab-panel" id="tab-about">
|
|
291
|
+
<div class="about-content">
|
|
292
|
+
<h3>SQL 智能助手 v1.0.0</h3>
|
|
293
|
+
<p>自然语言 → SQL → 查询结果</p>
|
|
294
|
+
<div class="about-features">
|
|
295
|
+
<h4>功能特性</h4>
|
|
296
|
+
<ul>
|
|
297
|
+
<li>自然语言转 SQL(增删改查)</li>
|
|
298
|
+
<li>支持 MySQL / SQL Server / PostgreSQL / Redis / MongoDB</li>
|
|
299
|
+
<li>支持 DeepSeek / 豆包 / Kimi / 通义千问 / Gemini / Claude / OpenAI</li>
|
|
300
|
+
<li>查询历史自动保存</li>
|
|
301
|
+
<li>流式响应</li>
|
|
302
|
+
</ul>
|
|
303
|
+
</div>
|
|
304
|
+
<div class="theme-section">
|
|
305
|
+
<h4>主题设置</h4>
|
|
306
|
+
<div class="theme-toggle">
|
|
307
|
+
<span>深色模式</span>
|
|
308
|
+
<label class="switch">
|
|
309
|
+
<input type="checkbox" id="theme-toggle-checkbox">
|
|
310
|
+
<span class="slider"></span>
|
|
311
|
+
</label>
|
|
312
|
+
<span>浅色模式</span>
|
|
313
|
+
</div>
|
|
314
|
+
<div class="color-picker">
|
|
315
|
+
<span>主题色:</span>
|
|
316
|
+
<div class="color-options">
|
|
317
|
+
<button class="color-btn" data-color="blue" title="蓝色"></button>
|
|
318
|
+
<button class="color-btn" data-color="purple" title="紫色"></button>
|
|
319
|
+
<button class="color-btn" data-color="pink" title="粉色"></button>
|
|
320
|
+
<button class="color-btn" data-color="red" title="红色"></button>
|
|
321
|
+
<button class="color-btn" data-color="orange" title="橙色"></button>
|
|
322
|
+
<button class="color-btn" data-color="yellow" title="黄色"></button>
|
|
323
|
+
<button class="color-btn" data-color="green" title="绿色"></button>
|
|
324
|
+
<button class="color-btn" data-color="cyan" title="青色"></button>
|
|
325
|
+
</div>
|
|
326
|
+
</div>
|
|
327
|
+
</div>
|
|
328
|
+
</div>
|
|
329
|
+
</div>
|
|
330
|
+
</div>
|
|
331
|
+
</div>
|
|
332
|
+
</div>
|
|
333
|
+
|
|
334
|
+
<!-- SQL 确认模态框 -->
|
|
335
|
+
<div class="modal-overlay" id="sql-confirm-modal">
|
|
336
|
+
<div class="modal-container" style="width: 640px;">
|
|
337
|
+
<div class="modal-header">
|
|
338
|
+
<h2 id="sql-confirm-title">⚠️ 确认执行 SQL</h2>
|
|
339
|
+
<button class="btn-icon" id="btn-close-sql-confirm">
|
|
340
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
|
|
341
|
+
</button>
|
|
342
|
+
</div>
|
|
343
|
+
<div class="modal-body">
|
|
344
|
+
<div id="sql-confirm-warning" class="sql-warning-box" style="display: none;"></div>
|
|
345
|
+
<div id="sql-confirm-reason" class="sql-reason-box"></div>
|
|
346
|
+
<div class="sql-preview-box">
|
|
347
|
+
<div class="sql-preview-header">
|
|
348
|
+
<span>📋 SQL 语句</span>
|
|
349
|
+
<button class="btn-copy" id="btn-copy-confirm-sql">复制</button>
|
|
350
|
+
</div>
|
|
351
|
+
<pre><code id="sql-confirm-code" class="language-sql"></code></pre>
|
|
352
|
+
</div>
|
|
353
|
+
<div class="sql-confirm-actions" style="margin-top: 20px; display: flex; gap: 12px; justify-content: flex-end;">
|
|
354
|
+
<button class="btn-text" id="btn-cancel-sql">取消</button>
|
|
355
|
+
<button class="btn-primary danger" id="btn-confirm-sql">确认执行</button>
|
|
356
|
+
</div>
|
|
357
|
+
</div>
|
|
358
|
+
</div>
|
|
359
|
+
</div>
|
|
360
|
+
|
|
361
|
+
<script src="/static/js/theme-manager.js"></script>
|
|
362
|
+
<script src="/static/js/color-theme-manager.js"></script>
|
|
363
|
+
<script src="/static/js/api.js"></script>
|
|
364
|
+
<script src="/static/js/ui.js"></script>
|
|
365
|
+
<script src="/static/js/state.js"></script>
|
|
366
|
+
<script src="/static/js/confirm.js"></script>
|
|
367
|
+
<script src="/static/js/chat.js"></script>
|
|
368
|
+
<script src="/static/js/conversations.js"></script>
|
|
369
|
+
<script src="/static/js/settings.js"></script>
|
|
370
|
+
<script src="/static/js/backup.js"></script>
|
|
371
|
+
<script src="/static/js/app.js"></script>
|
|
372
|
+
</body>
|
|
373
|
+
</html>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sql-assistant
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: SQL 智能助手 - 自然语言转 SQL 查询工具,支持主流数据库和 LLM
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Requires-Dist: aiosqlite>=0.20.0
|
|
8
|
+
Requires-Dist: fastapi>=0.110.0
|
|
9
|
+
Requires-Dist: httpx>=0.27.0
|
|
10
|
+
Requires-Dist: jinja2>=3.1.0
|
|
11
|
+
Requires-Dist: psycopg2-binary>=2.9.0
|
|
12
|
+
Requires-Dist: pydantic>=2.0.0
|
|
13
|
+
Requires-Dist: pymongo>=4.6.0
|
|
14
|
+
Requires-Dist: pymysql>=1.1.0
|
|
15
|
+
Requires-Dist: python-multipart>=0.0.9
|
|
16
|
+
Requires-Dist: pyyaml>=6.0
|
|
17
|
+
Requires-Dist: redis>=5.0.0
|
|
18
|
+
Requires-Dist: uvicorn[standard]>=0.29.0
|
|
19
|
+
Provides-Extra: claude
|
|
20
|
+
Requires-Dist: anthropic>=0.30.0; extra == 'claude'
|
|
21
|
+
Provides-Extra: gemini
|
|
22
|
+
Requires-Dist: google-generativeai>=0.8.0; extra == 'gemini'
|
|
23
|
+
Provides-Extra: sqlserver
|
|
24
|
+
Requires-Dist: pymssql>=2.3.0; extra == 'sqlserver'
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
sql_assistant/__init__.py,sha256=biiIwdbapVBMEDUSxSfipE5DFDKTkF8qnGfFwq0gR48,81
|
|
2
|
+
sql_assistant/config.py,sha256=2XdH27c3iu8tY5cW34B6z3SzmSIKJ9vUCBBEA67nUPs,4771
|
|
3
|
+
sql_assistant/main.py,sha256=j8M5-U6KfuIuZOmHQFbUUWoiEVTnIxOML7k6KbBqAtk,2193
|
|
4
|
+
sql_assistant/settings.py,sha256=LJDngs-1pmr2_4EtPVeGl77DkVZW-WElib3BT5df080,6831
|
|
5
|
+
sql_assistant/api/__init__.py,sha256=MYNGq3NjelRBWFz6PZUKBq8ql-mNrCnZqgObjFnJbBo,23
|
|
6
|
+
sql_assistant/api/backup.py,sha256=9JHUFmoktRCWorhpnCXjTSvHT3t9EdIYfGHHHgDnRNc,3465
|
|
7
|
+
sql_assistant/api/config.py,sha256=UrBaciQZ1_XRu7X1UWM2ElX3aUPvc2fBi6q8Dy8UeCs,6043
|
|
8
|
+
sql_assistant/api/conversation.py,sha256=smy1H_YRoIYuYf9d43AyKAxrQDckDkDH9GjvyKeV080,2783
|
|
9
|
+
sql_assistant/api/dependencies.py,sha256=i4RKa0eO3sAT3T68i2RaoyL6DO0PZWvufL3NOce7L0o,403
|
|
10
|
+
sql_assistant/api/history.py,sha256=Irc7bXzqu2O2Zl4-maBjYg9nCumZgPT4nQO0M2Gkx6U,1899
|
|
11
|
+
sql_assistant/api/models.py,sha256=tN21TdbE5aVf0iaA3sEprVhwE5Q9OEGPfeL7FgUJL08,6051
|
|
12
|
+
sql_assistant/api/query.py,sha256=qVYgc8WSBbyL3_rddGzhf7jNAJMGI_FE6jdpCHfInuI,9327
|
|
13
|
+
sql_assistant/api/routes.py,sha256=3-rQIblDF7T7lX95ZYuzFQUmv4zgbtiYdKUMqIvb36E,588
|
|
14
|
+
sql_assistant/api/schema.py,sha256=LHi1riORKxkUI0JnCe9TW8Oznvmp3t-dobqB81hzVx8,374
|
|
15
|
+
sql_assistant/database/__init__.py,sha256=ZV0y09xE0Nxh_eNrYWS36YlX6GoP61bAVw5hq1CMbVk,31
|
|
16
|
+
sql_assistant/database/backup.py,sha256=H4VcGzXDs009rE_rlGVsBdnRybh-y2rEI1cgfamC2nw,21214
|
|
17
|
+
sql_assistant/database/history.py,sha256=9ERE-a6kK5vBzd4b6EFBJKEZFE86S5PpJAgTfa7k0ig,10319
|
|
18
|
+
sql_assistant/database/manager.py,sha256=27Z0JQxiCPyLZ8645dfZvh2cGQcDxWus6VLM15gzsyY,6468
|
|
19
|
+
sql_assistant/database/security.py,sha256=AncFJ8wJv_Z17sSYxW48-1HZtXSP4Fp_I4JxZK-ng7w,7767
|
|
20
|
+
sql_assistant/database/connectors/__init__.py,sha256=QWxH8Y0LZ3VGxjgTyhnfg72MkuNeX-c6t8uVuGZphMg,31
|
|
21
|
+
sql_assistant/database/connectors/base.py,sha256=wGexI0HgCyJzNHBd532LzCVc34BT0M6455xaNc2VCjs,6170
|
|
22
|
+
sql_assistant/database/connectors/exceptions.py,sha256=TbbOfdAKglD0MO0k5fK6oL9aTTXUfaK9hmVhvhCtGTc,2328
|
|
23
|
+
sql_assistant/database/connectors/mongodb.py,sha256=gQFW_LXde5FoBRvB14_g0VhMTJnlqXW-t59YR01N3Uc,7849
|
|
24
|
+
sql_assistant/database/connectors/mysql.py,sha256=jVMfzCin9J2NMl-R1PHO41oGsZhXz34ct0HnDTCoMlA,3872
|
|
25
|
+
sql_assistant/database/connectors/postgresql.py,sha256=-gVD23iwJJBgP00kybL_PhRcQYIQ0AE7kO9h0VtmSK4,4909
|
|
26
|
+
sql_assistant/database/connectors/redis.py,sha256=wvH3qyPup2Yb4vqW-yGdEoAt4FL_dfwu05sgqeKC5hw,4387
|
|
27
|
+
sql_assistant/database/connectors/sqlserver.py,sha256=l-WK7HbQCn1U5zAFuaVqOaI6TGypTd-S86wWI53nz9g,5070
|
|
28
|
+
sql_assistant/llm/__init__.py,sha256=3xwN_JqcIp4JSrB7QA3gXu96Qz3PKCN7c51ZzQSjXL0,23
|
|
29
|
+
sql_assistant/llm/base.py,sha256=vH357Dm7Key4vfNna2_gEMp8pkXsoHX8xM5sbXqjD6Q,805
|
|
30
|
+
sql_assistant/llm/exceptions.py,sha256=cVBcPditXziKueUlUr1V4ZDYK-Ru7nBLlLTjIOCdNSE,2712
|
|
31
|
+
sql_assistant/llm/manager.py,sha256=cbElRsijV6OuHwb9nw95BlXOUfjyq4clUvAneDyC_sk,3020
|
|
32
|
+
sql_assistant/llm/prompts.py,sha256=djQEyIefYBWrnhaX0BDv65MkjZJvpXhvCNiHkHeymoQ,1387
|
|
33
|
+
sql_assistant/llm/retry.py,sha256=FM3liGjtGdBDKIKoSDz7swHDVDP_RYc37yMT0to_U-A,2558
|
|
34
|
+
sql_assistant/llm/providers/__init__.py,sha256=6ZOWMxNTnk2XPrYsvFN9luWW2NFCyF8H5OOvvlC63eQ,26
|
|
35
|
+
sql_assistant/llm/providers/claude.py,sha256=iYZgNU07xTkz4cxF97nsmYfrQE91m0egf5Tq5dblllo,5118
|
|
36
|
+
sql_assistant/llm/providers/gemini.py,sha256=hb_T3mBMOp2CXlwmJe1laDzhR6BjBmLbnEyFfSgLBxA,5320
|
|
37
|
+
sql_assistant/llm/providers/openai_compatible.py,sha256=nb9E97QaFXAi6HUWtu3j9Ez3NbvBz9vdPe1wE4Jm4D4,4251
|
|
38
|
+
sql_assistant/web/__init__.py,sha256=66u2oO2bEGPpMeskAV5y7NmlQNu4lyFhTrls9eazOZw,23
|
|
39
|
+
sql_assistant/web/static/css/base.css,sha256=HxCWErl5VRuwWzXSCDe_4JVs76Z7vBmn-STEZEtydrA,636
|
|
40
|
+
sql_assistant/web/static/css/style.css,sha256=tXLW8XidOb0T71vYAXU5PQc_kPs59X25Zl7iTDobmEc,327
|
|
41
|
+
sql_assistant/web/static/css/theme.css,sha256=o24TnKZAg0DT5vf1DnA-a3lbrcfE9NTFXdp-5Co9IZk,4437
|
|
42
|
+
sql_assistant/web/static/css/components/backup.css,sha256=odb6Q_Ubi3Knp9OFkQhZiQlrpz3m4ddCP9lyBieSgGg,2722
|
|
43
|
+
sql_assistant/web/static/css/components/chat.css,sha256=iSDgEXWMItTyyhwgqb5Yq2T_RnA4APvgBibF6VrwEbw,9401
|
|
44
|
+
sql_assistant/web/static/css/components/modal.css,sha256=jmICiXzgSRkRs9Uuz8oXbOpNsmzFTeJM670e35_UVdo,2893
|
|
45
|
+
sql_assistant/web/static/css/components/settings.css,sha256=lZHeA0KeD32pb-CAeOEY1JdoXGPcOHFMavYpMcq7u1g,7071
|
|
46
|
+
sql_assistant/web/static/css/components/sidebar.css,sha256=SV4apjZKz8zVRNGt4AfO2rQ0_TtsMee8oG_OW4WRvXI,4763
|
|
47
|
+
sql_assistant/web/static/css/components/toast.css,sha256=SO6CoHzpB0ziiWwYaIA8T87MDY4dWOqinkvkWNt2R9c,841
|
|
48
|
+
sql_assistant/web/static/js/api.js,sha256=WroU5uazklq0KO_ac3BAmVdcyXXW1CERaoo9yPoj3Sc,1098
|
|
49
|
+
sql_assistant/web/static/js/app.js,sha256=9wtAFR46HWKocjHgRX7GMCifKMFti6wK_ZnxDKz4i1M,5514
|
|
50
|
+
sql_assistant/web/static/js/backup.js,sha256=yE5FDPzK17e8XdH23Yd_IBeKNsiEkaKhh6qnwIrp4ek,7507
|
|
51
|
+
sql_assistant/web/static/js/chat.js,sha256=iqKtpr5S7O6KYC3J0GDGiCUjppfFWaHqn27XOaVrz6A,8502
|
|
52
|
+
sql_assistant/web/static/js/color-theme-manager.js,sha256=Y-kAJbMxR5F4eMPR8cT5In9e7m3ttUKbgXVXpougxiU,3035
|
|
53
|
+
sql_assistant/web/static/js/confirm.js,sha256=j4I1v7lGP6pCffLGzc__G-Bpufi4sxF5UezTGLPTQHY,3220
|
|
54
|
+
sql_assistant/web/static/js/conversations.js,sha256=vkiWd1_33u5wtQwlM7jgbpHafphKjpcRfEaHc_zLKxY,7378
|
|
55
|
+
sql_assistant/web/static/js/settings.js,sha256=IrS4cKmzz2EI_dZZiToanFpm3obmVEOxsNywoBpQaUE,14765
|
|
56
|
+
sql_assistant/web/static/js/state.js,sha256=vudWLWUXg3tdrismr8nUPuFl2wgccNjwMlCLp1J7iSc,961
|
|
57
|
+
sql_assistant/web/static/js/theme-manager.js,sha256=wvit0tMf_l3uNuq_J-XUVKOW2WniInppkHagXBCJHm4,1647
|
|
58
|
+
sql_assistant/web/static/js/ui.js,sha256=8mJEcM0reVQZcuBVB4_N_RCNG5JkMkM8WshZe8kAtds,1609
|
|
59
|
+
sql_assistant/web/templates/index.html,sha256=j68-fi_1ZXi8GSZMA5IHdbqjv_W5OrJwm0b1_o0f8nI,22584
|
|
60
|
+
sql_assistant-1.0.0.dist-info/METADATA,sha256=yw8nTUQE-mWbKvmoMX9W-voSrQPjIrIfgS6s9sJmICs,819
|
|
61
|
+
sql_assistant-1.0.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
62
|
+
sql_assistant-1.0.0.dist-info/entry_points.txt,sha256=Xj3YqNma69a_wTEI3bNBvEGRBTv4GKKq-K_vfKUvYes,58
|
|
63
|
+
sql_assistant-1.0.0.dist-info/licenses/LICENSE,sha256=QegxlFBkcy8Ya0j61VT3oIjWavCuQnUpt2axobTt0k4,1066
|
|
64
|
+
sql_assistant-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 fjz-hosts
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|