Subversion Repositories MLServ

Rev

Rev 5 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

/* $Id: db.c 7 2024-09-25 00:56:55Z nishi $ */

#include "cm_db.h"

#include <sqlite3.h>

#include <stddef.h>

sqlite3* cm_db_init(void) {
        int ret;
        sqlite3* sql;
        ret = sqlite3_open(DB_PATH, &sql);
        if(ret != SQLITE_OK) {
                return NULL;
        }
        ret = sqlite3_exec(sql, "create table if not exists lists(name text, description text)", NULL, NULL, NULL);
        if(ret != SQLITE_OK) {
                sqlite3_close(sql);
                return NULL;
        }
        ret = sqlite3_exec(sql, "create table if not exists users(email text, password text)", NULL, NULL, NULL);
        if(ret != SQLITE_OK) {
                sqlite3_close(sql);
                return NULL;
        }
        ret = sqlite3_exec(sql, "create table if not exists tokens(list text, email text, token text, expire numeric)", NULL, NULL, NULL);
        if(ret != SQLITE_OK) {
                sqlite3_close(sql);
                return NULL;
        }
        return sql;
}

char** cm_list_ml(sqlite3* sql) { return NULL; }