aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Wang2022-04-19 13:04:37 -0500
committerAnthony Wang2022-04-19 13:04:37 -0500
commitb95cdd56c2124f7545898e194ee8ad740b161678 (patch)
tree5e54e4480bfd54a4533466766bfcfa7b42438d6d
parent9009a690b916de3e98f33a11629d572d4c50f97b (diff)
Actually modify db
-rw-r--r--cd.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/cd.c b/cd.c
index 7d0cb0b..9b87512 100644
--- a/cd.c
+++ b/cd.c
@@ -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);
}