Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/htfy96/nanosql
Nano encapsulation of SQLite with transaction support
https://github.com/htfy96/nanosql
Last synced: about 2 months ago
JSON representation
Nano encapsulation of SQLite with transaction support
- Host: GitHub
- URL: https://github.com/htfy96/nanosql
- Owner: htfy96
- License: mit
- Created: 2015-03-22T05:58:31.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-03-22T06:00:15.000Z (almost 10 years ago)
- Last Synced: 2023-02-26T18:11:53.541Z (almost 2 years ago)
- Language: C++
- Size: 137 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
> NanoSQL是一个简单封装的C++ Sqlite3库,支持简单的事务,同时具有方便、迅速的语法
#基本内容
##Sql类
一个实例对应一个文件
```cpp
class Sql
{
Sql(const std::string& filename); //文件名
~Sql(); //安全析构
Res raw_result; // by get_table(query)
std::string lasterr; //上一个错误
bool is_tran() const; //是否在一个事务中?
int exec(const std::string& query, CallbackFunc cb=NULL); //执行语句,回调函数可以省略
int get_table(const std::string& query); //把得到的table存到raw_result中
inline char* result(long row, long col); //从1开始,快速获得raw_result中的结果
inline char* colName(long col); //读取自raw_result
int begin_tran(); //进入事务状态,错误会抛出runtime_error
int end_tran(); //离开事务状态,错误会抛出runtime_error
};
```
##Res类
保存`get_table`的结果,析构时安全释放
```cpp
typedef struct
{
char **arr;
int row, col;
} Res;
```
#实例
详见目录下的`example.cpp`