(db_type: Union[str, DB])
| 30 | |
| 31 | |
| 32 | def 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 | |
| 48 | def get_all_sql_templates(): |
no test coverage detected