Skip to content

Commit b520a4e

Browse files
committed
feat: template
1 parent a384421 commit b520a4e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

backend/apps/template/template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
def load():
7-
with open('./template.yaml', 'r') as f:
7+
with open('./template.yaml', 'r', encoding='utf-8') as f:
88
global base_template
99
base_template = yaml.load(f, Loader=yaml.SafeLoader)
1010

backend/template.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ template:
77
- 生成的SQL必须符合{engine}的规范。
88
- 根据表结构生成SQL语句。
99
- SQL查询中不能使用星号(*),必须明确指定字段名.
10-
- SQL查询的字段名和别名必须为英文
10+
- SQL查询的字段名不要自动翻译,别名必须为英文
1111
- 计算占比,百分比类型字段,保留两位小数,以%结尾。
12+
- 生成SQL时,必须避免关键字冲突:
13+
- 如{engine}是 PostgreSQL、Oracle,则在schema、表名、字段名、别名外层加双引号;
14+
- 如{engine}是 MySQL,则在表名、字段名、别名外层加反引号;
15+
- 如{engine}是 Microsoft SQL Server,则在schema、表名、字段名、别名外层加方括号。
1216
- 生成的SQL使用JSON格式返回:
1317
{{"success":true,"sql":"生成的SQL语句"}}
1418
- 问题与生成SQL无关时,直接回答:

0 commit comments

Comments
 (0)