Wrap sqlite.h in sql.hpp
This commit is contained in:
@@ -1,18 +1,36 @@
|
||||
#include <cinttypes>
|
||||
|
||||
|
||||
const char create_table[] = "CREATE TABLE IF NOT EXISTS prim_table ( ID INTEGER PRIMARY KEY, USER_ID INTEGER, GEN INTEGER, HASH INTEGER, POS INTEGER, LIKED INTEGER);";
|
||||
const char create_table[] = "CREATE TABLE IF NOT EXISTS prim_table ( ID INTEGER PRIMARY KEY, USER_ID INTEGER, GEN INTEGER, HASH INTEGER, POS INTEGER, LIKED INTEGER, CHECKED INTEGER);";
|
||||
|
||||
const char create_index[] = "CREATE INDEX IF NOT EXISTS idx_usrer_id ON prim_table (USER_ID);";
|
||||
|
||||
const char insert_data[] = "INSERT INTO prim_table (USER_ID, GEN, HASH, POS, LIKED) VALUES(?, ?, ?, ?, ?);";
|
||||
const char insert_data[] = "INSERT INTO prim_table (USER_ID, GEN, HASH, POS, LIKED, CHECKED) VALUES(?, ?, ?, ?, ?, 0);";
|
||||
|
||||
const char max_gen[] = "SELECT MAX(GEN) FROM prim_table WHERE USER_ID = ?;";
|
||||
|
||||
const char get_unchecked[] = "SELECT USER_ID FROM prim_table WHERE CHECKED = 0 GROUP BY USER_ID;";
|
||||
|
||||
constexpr char DB_NAME[] = "data.db";
|
||||
|
||||
struct sqlite3;
|
||||
struct sqlite3_stmt;
|
||||
|
||||
#define SQL_DONE 101
|
||||
#define SQL_NULL 5
|
||||
|
||||
namespace sql
|
||||
{
|
||||
void init();
|
||||
void shutdown();
|
||||
|
||||
int open(const char *filename, sqlite3 **ppDb);
|
||||
int prepare_v2(sqlite3 *db, const char *zSql, int nByte, sqlite3_stmt **pStmt, const char **pzTail);
|
||||
int bind_int64(sqlite3_stmt *pStmt, int column, int64_t value);
|
||||
int step(sqlite3_stmt *pStmt);
|
||||
int column_count(sqlite3_stmt *pStmt);
|
||||
int column_type(sqlite3_stmt *pStmt, int column);
|
||||
int64_t column_int64(sqlite3_stmt *pStmt, int column);
|
||||
int finalize(sqlite3_stmt *pStmt);
|
||||
int reset(sqlite3_stmt *pStmt);
|
||||
int close(sqlite3 *db);
|
||||
const char *errmsg(sqlite3 *db);
|
||||
}
|
||||
|
Reference in New Issue
Block a user