eis/mix_cc/sql/readme.md

38 lines
1.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# mix_cc::sql
## 一个简易的高效的c++ sql接口和查询库
## 项目依赖
1. 编译器最低支持 c++17/20 (17会导致一处的异常处理无法使用)
2. sqlapi++
3. boost 1.75(min)
## 目前支持的字段包括
1. select
2. from
3. where
4. insert_into
5. update
6. set
7. delete_from
## 使用流程
1. 使用make_table中的宏MIX_CC_SQL_MAKE_TABLE(表名,(列属性1,列名1),(列属性2,列名2),...(列属性n,列名n),) n <= 40 构建目标表
2. 使用sql字段构建sql语句
```c++
auto sql_statement =
select(t_rule_cfg.algId(), t_rule_cfg.ruleId(), t_rule_cfg.ruleName(),
t_rule_cfg.flag(), t_rule_cfg.ruleParam())
.from(t_rule_cfg).where(t_rule_cfg.aldId()==40);
```
3. 使用exec<db_type>(sql_statement)函数执行sql语句其中查询的exec不同为exec(表名sql语句))
4. 使用auto类型接受exec函数的执行结果,其中查询为表的行数组,其它为受影响的行数
## 注意事项
1. 目前支持的数据库类型仅为db2
2. 目前支持的数据类型包含 intdoublecharstringmix_cc::mix_time(对应db2中time_stamp)
3. 目前字符不支持特殊字符需要更改对sqlapi++的使用方式