MCPcopy Index your code
hub / github.com/dataease/SQLBot / get_sql_template

Function get_sql_template

backend/apps/template/template.py:32–45  ·  view source on GitHub ↗
(db_type: Union[str, DB])

Source from the content-addressed store, hash-verified

30
31
32def get_sql_template(db_type: Union[str, DB]):
33 # 处理输入参数
34 if isinstance(db_type, str):
35 # 如果是字符串,查找对应的枚举值,找不到则使用默认的 DB.pg
36 db_enum = DB.get_db(db_type, default_if_none=True)
37 elif isinstance(db_type, DB):
38 db_enum = db_type
39 else:
40 db_enum = DB.pg
41
42 # 使用 template_name 作为文件名
43 template_path = SQL_TEMPLATES_DIR / f"{db_enum.template_name}.yaml"
44
45 return _load_template_file(template_path)
46
47
48def get_all_sql_templates():

Callers 1

get_all_sql_templatesFunction · 0.70

Calls 2

_load_template_fileFunction · 0.85
get_dbMethod · 0.80

Tested by

no test coverage detected