fix lua dbupdate

write sqlite data to a temporary db by default (configurable).
This commit is contained in:
Enno Rehling 2017-11-10 16:29:48 +01:00
parent f8e552ab6e
commit 6923fe5c53
2 changed files with 4 additions and 4 deletions

View File

@ -29,7 +29,7 @@ local function dbupdate()
update_scores() update_scores()
if config.dbname then if config.dbname then
dbname = config.basepath..'/'..config.dbname dbname = config.basepath..'/'..config.dbname
edb = db.open(dbame) edb = db.open(dbname)
if edb~=nil then if edb~=nil then
edb:update_factions() edb:update_factions()
edb:update_scores() edb:update_scores()

View File

@ -1,6 +1,7 @@
#include <platform.h> #include <platform.h>
#include "db.h" #include "db.h"
#include "orderdb.h" #include "orderdb.h"
#include "config.h"
#include <util/log.h> #include <util/log.h>
@ -11,8 +12,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#define DBNAME ":memory:"
static sqlite3 *g_db; static sqlite3 *g_db;
static sqlite3_stmt * g_stmt_insert; static sqlite3_stmt * g_stmt_insert;
static sqlite3_stmt * g_stmt_select; static sqlite3_stmt * g_stmt_select;
@ -65,8 +64,9 @@ int db_save_order(order_data *od)
void db_open(void) void db_open(void)
{ {
int err; int err;
const char *dbname = config_get("config.dbname", "");
err = sqlite3_open(DBNAME, &g_db); err = sqlite3_open(dbname, &g_db);
assert(err == SQLITE_OK); assert(err == SQLITE_OK);
err = sqlite3_exec(g_db, "CREATE TABLE IF NOT EXISTS orders (id INTEGER PRIMARY KEY, data TEXT NOT NULL)", NULL, NULL, NULL); err = sqlite3_exec(g_db, "CREATE TABLE IF NOT EXISTS orders (id INTEGER PRIMARY KEY, data TEXT NOT NULL)", NULL, NULL, NULL);
assert(err == SQLITE_OK); assert(err == SQLITE_OK);