dont make me stare at sql
This commit is contained in:
parent
59a295a756
commit
cbb1f3e3a4
46
include/sql_stmt.inc
Normal file
46
include/sql_stmt.inc
Normal file
@ -0,0 +1,46 @@
|
||||
VARDECL sqlite3_stmt * remind_stmt;
|
||||
VARDECL char const remind_stmt_template[] =
|
||||
"SELECT "
|
||||
"title,"
|
||||
"body,"
|
||||
"difficulty,"
|
||||
"repo_link,"
|
||||
"trigger_date,"
|
||||
"started DATE,"
|
||||
"span"
|
||||
" FROM assignment INNER JOIN project on assignment.project = project.rowid "
|
||||
"WHERE who = ?;";
|
||||
|
||||
VARDECL sqlite3_stmt * set_repo_stmt;
|
||||
VARDECL char const set_repo_stmt_template[] =
|
||||
"UPDATE assignment "
|
||||
"SET "
|
||||
"repo_link = ? "
|
||||
"WHERE who = ?;";
|
||||
|
||||
VARDECL char const dump_stmt[] =
|
||||
"SELECT * FROM project;";
|
||||
|
||||
VARDECL sqlite3_stmt * get_nth_id_stmt;
|
||||
VARDECL char const get_nth_id_stmt_template[] =
|
||||
"SELECT rowid "
|
||||
"FROM project "
|
||||
"LIMIT 1 "
|
||||
"OFFSET ?;";
|
||||
|
||||
VARDECL sqlite3_stmt * new_assignment_stmt;
|
||||
VARDECL char const new_assignment_stmt_template[] =
|
||||
"INSERT INTO assignment "
|
||||
"(who, project)"
|
||||
" VALUES "
|
||||
"(?, ?);";
|
||||
|
||||
VARDECL sqlite3_stmt * purge_assignments_stmt;
|
||||
VARDECL char const purge_assignments_stmt_template[] =
|
||||
"DELETE FROM assignment "
|
||||
"WHERE who = ?;";
|
||||
|
||||
VARDECL sqlite3_stmt* is_no_assignment_stmt;
|
||||
VARDECL const char is_no_assignment_stmt_template[] =
|
||||
"SELECT * FROM assignment "
|
||||
"WHERE who = ?;" ;
|
47
src/api.c
47
src/api.c
@ -3,53 +3,6 @@
|
||||
#define stmt_prepare(stmt) \
|
||||
sqlite3_prepare_v2(connection, stmt ## _template, -1, &stmt, NULL)
|
||||
|
||||
VARDECL sqlite3_stmt * remind_stmt;
|
||||
VARDECL char const remind_stmt_template[] =
|
||||
"SELECT "
|
||||
"title,"
|
||||
"body,"
|
||||
"difficulty,"
|
||||
"repo_link,"
|
||||
"trigger_date,"
|
||||
"started DATE,"
|
||||
"span"
|
||||
" FROM assignment INNER JOIN project on assignment.project = project.rowid "
|
||||
"WHERE who = ?;";
|
||||
|
||||
VARDECL sqlite3_stmt * set_repo_stmt;
|
||||
VARDECL char const set_repo_stmt_template[] =
|
||||
"UPDATE assignment "
|
||||
"SET "
|
||||
"repo_link = ? "
|
||||
"WHERE who = ?;";
|
||||
|
||||
VARDECL char const dump_stmt[] =
|
||||
"SELECT * FROM project;";
|
||||
|
||||
VARDECL sqlite3_stmt * get_nth_id_stmt;
|
||||
VARDECL char const get_nth_id_stmt_template[] =
|
||||
"SELECT rowid "
|
||||
"FROM project "
|
||||
"LIMIT 1 "
|
||||
"OFFSET ?;";
|
||||
|
||||
VARDECL sqlite3_stmt * new_assignment_stmt;
|
||||
VARDECL char const new_assignment_stmt_template[] =
|
||||
"INSERT INTO assignment "
|
||||
"(who, project)"
|
||||
" VALUES "
|
||||
"(?, ?);";
|
||||
|
||||
VARDECL sqlite3_stmt * purge_assignments_stmt;
|
||||
VARDECL char const purge_assignments_stmt_template[] =
|
||||
"DELETE FROM assignment "
|
||||
"WHERE who = ?;";
|
||||
|
||||
VARDECL sqlite3_stmt* is_no_assignment_stmt;
|
||||
VARDECL const char is_no_assignment_stmt_template[] =
|
||||
"SELECT * FROM assignment "
|
||||
"WHERE who = ?;" ;
|
||||
|
||||
VARDECL char const * db = DBFILE;
|
||||
|
||||
VARDECL sqlite3 * connection = NULL;
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#include <sqlite3.h>
|
||||
|
||||
#include "sql_stmt.inc"
|
||||
|
||||
#include "api.h"
|
||||
#include "error.h"
|
||||
#include "free.h"
|
||||
|
Reference in New Issue
Block a user