How to commit a SQLite transaction in C/C++?

前端 未结 1 762
情歌与酒
情歌与酒 2021-01-01 17:45

I am using sqlite c/c++ interface.

I have 3 tables (related tables) say A, B, C. Now, there is a function called Set, which get some inputs and base

相关标签:
1条回答
  • 2021-01-01 18:08

    You use sqlite3_exec and pass "BEGIN TRANSACTION" and "END TRANSACTION" respectively.

    // 'db' is the pointer you got from sqlite3_open*
    sqlite3_exec(db, "BEGIN TRANSACTION;", NULL, NULL, NULL);
    // Any (modifying) SQL commands executed here are not committed until at the you call:
    sqlite3_exec(db, "END TRANSACTION;", NULL, NULL, NULL);
    

    There are synonyms for these SQL commands (like COMMIT instead of END TRANSACTION). For reference, here is the SQLite documentation for transactions.

    0 讨论(0)
提交回复
热议问题