8 static int callback(
void * junk __attribute__((unused)),
int cnt,
char ** vals,
char ** col_name)
12 for (i = 0; i < cnt; ++
i) {
14 printf(
"%s: %s\n", col_name[i], vals[i]);
17 printf(
"%s: %s\n", col_name[i],
"NULL");
28 if (argc < 2 || argc > 3) {
29 fprintf(
stderr,
"usage: %s: <db-filename> [<sql-statement>]. If <sql-statement> is omitted take from stdin.\n", argv[0]);
33 err = sqlite3_open_v2(argv[1], &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
"myvfs");
35 fprintf(
stderr,
"Can't open database: %s\n", sqlite3_errmsg(db));
40 err = sqlite3_exec(db, argv[2],
callback, 0, &error_msg);
45 getline(&buf, &n, stdin);
46 err = sqlite3_exec(db, buf,
callback, 0, &error_msg);
49 if (err != SQLITE_OK) {
50 fprintf(
stderr,
"SQL error: %s\n", error_msg);
51 sqlite3_free(error_msg);
static int callback(void *junk __attribute__((unused)), int cnt, char **vals, char **col_name)
int main(int argc, char **argv)