Browse Source

db get_project count // for finding a random one

pull/3/head
anon 10 months ago
parent
commit
b7e72910ce
1 changed files with 18 additions and 0 deletions
  1. +18
    -0
      src/api.c

+ 18
- 0
src/api.c View File

@@ -132,3 +132,21 @@ raw(const char * const sql)
} else { strcat(r, "\00"); }
return r;
}


static int get_project_count_callback(void* data, int argc, char** argv, char** colname) {
(void)argc;
(void)colname;
int* count = (int*)data;
*count = atoi(argv[0]);
return 0;
}

static int get_project_count(){
int r = 0;

const char* sql = "SELECT COUNT(*) FROM project;";
DBERR(sqlite3_exec(connection, sql, get_project_count_callback, &r, NULL));

return r;
}