diff options
author | Anthony Wang | 2022-04-19 13:04:37 -0500 |
---|---|---|
committer | Anthony Wang | 2022-04-19 13:04:37 -0500 |
commit | b95cdd56c2124f7545898e194ee8ad740b161678 (patch) | |
tree | 5e54e4480bfd54a4533466766bfcfa7b42438d6d | |
parent | 9009a690b916de3e98f33a11629d572d4c50f97b (diff) |
Actually modify db
-rw-r--r-- | cd.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -42,7 +42,7 @@ int main(int argc, char* argv[]) { /* Get number of cards */ sqlite3_stmt *stmt; rc = sqlite3_prepare_v3(db, "SELECT COUNT(*) FROM cards", -1, 0, &stmt, NULL); - if (rc != SQLITE_OK) { + if (rc) { fprintf(stderr, "Database error: %s\n", sqlite3_errmsg(db)); abort(); } @@ -52,7 +52,7 @@ int main(int argc, char* argv[]) { /* Get card weights */ rc = sqlite3_prepare_v3(db, "SELECT weight FROM cards", -1, 0, &stmt, NULL); - if (rc != SQLITE_OK) { + if (rc) { fprintf(stderr, "Database error: %s\n", sqlite3_errmsg(db)); abort(); } @@ -83,7 +83,7 @@ int main(int argc, char* argv[]) { /* Get card contents from database */ rc = sqlite3_prepare_v3(db, "SELECT key, val FROM cards WHERE idx=?", -1, 0, &stmt, NULL); - if (rc != SQLITE_OK) { + if (rc) { fprintf(stderr, "Database error: %s\n", sqlite3_errmsg(db)); abort(); } @@ -115,12 +115,13 @@ int main(int argc, char* argv[]) { /* Update segment tree and database */ update(i, w, 0, N - 1, 1); rc = sqlite3_prepare_v3(db, "UPDATE cards SET weight=? WHERE idx=?", -1, 0, &stmt, NULL); - if (rc != SQLITE_OK) { + if (rc) { fprintf(stderr, "Database error: %s\n", sqlite3_errmsg(db)); abort(); } sqlite3_bind_int(stmt, 1, w); sqlite3_bind_int(stmt, 2, i); + sqlite3_step(stmt); sqlite3_finalize(stmt); } |