db get_project count // for finding a random one

This commit is contained in:
anon 2023-08-03 13:37:55 +02:00
parent 0d7a6fe891
commit b7e72910ce

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;
}