如何打印在这样的部分代码中执行的实际最终 sqlite3 查询?
int rc;
sqlite3_stmt *res;
char *query = "";
query = "SELECT count(*) FROM `db_report` WHERE `r_sn` = ?;";
rc = sqlite3_prepare_v2(db, query, -1, &res, 0);
if (rc == SQLITE_OK)
{
sqlite3_bind_text(res, 1, sn, strlen(sn), SQLITE_STATIC);
}
int step = sqlite3_step(res);
PRINT REAL QUERY
sqlite3_finalize(res);
return 0;
非常感谢 :)
最佳答案
您可以使用 sqlite3_expanded_sql
检索指向包含扩展绑定(bind)参数的最终查询的字符串的指针。
关于C sqlite3如何在准备和绑定(bind)后打印实际查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42526007/