|
NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
|
数据库连接抽象基类 更多...
#include <db_interface.hpp>
Public 类型 | |
| using | clock_type = milliseconds |
| 存活时间计时器类型 | |
Public 成员函数 | |
| virtual bool | update (const string &sql) const =0 |
| 执行非查询SQL语句 | |
| void | refresh_alive () noexcept |
| 刷新连接存活时间 | |
| NEFORCE_NODISCARD clock_type | get_alive () const noexcept |
| 获取连接空闲时间 | |
连接管理 | |
| virtual bool | connect (const db_config &config)=0 |
| 建立连接 | |
| virtual bool | reconnect (const db_config &config)=0 |
| 重新连接 | |
| virtual void | close ()=0 |
| 关闭连接 | |
字符集设置 | |
| virtual bool | set_character_set (const string &encoding) const =0 |
| 设置字符集 | |
| virtual string_view | get_character_set () const =0 |
| 获取字符集 | |
错误处理 | |
| virtual string_view | get_error () const =0 |
| 获取错误信息 | |
| virtual uint32_t | get_errno () const =0 |
| 获取错误码 | |
连接状态检测 | |
| virtual bool | connected () const =0 |
| 检查连接状态 | |
| virtual bool | is_valid () const =0 |
| 检查连接有效性 | |
|
inlinenoexcept |
|
inlinenoexcept |
刷新连接存活时间
标记当前连接为活动状态,用于连接池空闲检测。
在文件 db_interface.hpp 第 245 行定义.
引用了 steady_clock::now() , 以及 time_cast().
|
pure virtual |
执行非查询SQL语句
| sql | SQL语句 |
在 mysql_connect, pgsql_connect, redis_connect , 以及 sqlite_connect 内被实现.