[C++] sqlite3_get_table 的使用

不知道为啥 sqlite3 里面使用 "UPDATE" 更新数据,更新失败也不报错,所以就想绕过去。先查一下字段存在不存在,然后再update

cpp 复制代码
std::string selectsql =  "SELECT COUNT(*) FROM table_name WHERE some_condition";
char** dbResult;
char* errmsg = NULL;        //用来存储错误信息字符串
int nRow = 0, nColumn = 0;  // nRow  查找出的总行数,nColumn 存储列
int ret = sqlite3_get_table(db, selectsql.c_str(), &dbResult, &nRow, &nColumn, &errmsg);
if (SQLITE_OK != ret || nRow == 0)
{

    sqlite3_free_table(dbResult);
   // do_something
}
 sqlite3_free_table(dbResult);
// do_something


std::string sql = "UPDATE table_name SET item1=? \
    WHERE item2=? and item3=? and item4=?;  ";

sqlite3_prepare_v2(db, sql.c_str(), -1, &statement, nullptr);
int index = 0;
QByteArray inByteArray
sqliteBind(statement, index, inByteArray.data(), inByteArray.length());  
sqliteBind(statement, index, "...");         
sqliteBind(statement, index, "...");  
sqliteBind(statement, index, "...");    
相关推荐
正儿八经的少年16 小时前
Spring 事务保证数据一致性
java·数据库·spring
foo1st16 小时前
MySQL 8.0(Windows)升级笔记
数据库·笔记·mysql
张人玉16 小时前
基于 Vue 3 + ECharts + Express + SQLite 的可视化大屏与业务管理系统——YOLOv8 高精度车辆行人检测与计数系统
数据库·vue.js·yolo·sqlite·echarts·express
吴声子夜歌17 小时前
MongoDB 4.x——高级特性(Change Stream和事务)
数据库·mongodb
是店小二呀17 小时前
NanoPi R4S怎么搭私人云盘?iStoreOS与WebDAV完整教程
数据库·人工智能
呜喵王阿尔萨斯17 小时前
C/C++ const -- 多义混乱
c语言·开发语言·c++
海清河晏11117 小时前
Qt实战:从零构建美化登录界面
开发语言·c++·qt
Database_Cool_17 小时前
云数据库备份是怎么实现的、支持时间点恢复吗:阿里云 RDS MySQL 备份与 PITR 详解
数据库·mysql·阿里云
一只小灿灿17 小时前
C++ 各类特殊符号、运算符
开发语言·c++
名字还没想好☜17 小时前
Go 的 select 实战:超时、非阻塞收发与优雅退出的三个套路
开发语言·数据库·golang·go·并发