Bugs
This commit is contained in:
parent
823330dde9
commit
542e8395ef
7
db.c
7
db.c
@ -106,7 +106,7 @@ int run_script(sqlite3 * db, const char *script_filename) {
|
||||
}
|
||||
|
||||
int run_one(sqlite3 * db, const char *query) {
|
||||
int i, rc;
|
||||
int i, n, rc;
|
||||
sqlite3_stmt *stmt = NULL;
|
||||
|
||||
printf("> %s\n", query);
|
||||
@ -115,13 +115,14 @@ int run_one(sqlite3 * db, const char *query) {
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
while (SQLITE_ROW == (rc = sqlite3_step(stmt))) {
|
||||
for (i = 0; i < sqlite3_column_count(stmt); ++i) {
|
||||
n = sqlite3_column_count(stmt);
|
||||
for (i = 0; i < n; ++i) {
|
||||
printf(" => ");
|
||||
print_col(stmt, i);
|
||||
puts("");
|
||||
}
|
||||
}
|
||||
if (SQLITE_DONE != (rc = sqlite3_step(stmt))) {
|
||||
if (SQLITE_DONE != rc) {
|
||||
fprintf(stderr, errmsg_update, sqlite3_errmsg(db));
|
||||
}
|
||||
if (SQLITE_OK != (rc = sqlite3_reset(stmt))) {
|
||||
|
11
main.c
11
main.c
@ -149,15 +149,14 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
if (NULL != db_name) {
|
||||
rc = sqlite3_open(db_name, &db);
|
||||
if (SQLITE_OK != rc) {
|
||||
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if (SQLITE_OK == (rc = sqlite3_open(db_name, &db))) {
|
||||
printf("Open database successfully: ");
|
||||
sqlite_version(db);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
|
||||
return -1;
|
||||
}
|
||||
|
||||
run_one(db, "create table if not exists quotedb (date_added text not null, added_by text not null, channel text not null, subject text not null, words text not null)");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user