From 994411d470ae3d7a7649fc43f76f180c7287ce43 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Wed, 18 Mar 2020 18:42:16 +0100 Subject: [PATCH] database: create table --- src/database.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/database.c b/src/database.c index 3ac203e3..c03c2466 100644 --- a/src/database.c +++ b/src/database.c @@ -57,7 +57,19 @@ log_database_init(void) return FALSE; } - log_error("Initialized SQLite database: %s", filename); + char *err_msg; + char *query = "CREATE TABLE IF NOT EXISTS `ChatLogs` ( `id` INTEGER PRIMARY KEY, `jid` TEXT NOT NULL, `message` TEXT, `timestamp` TEXT)"; + if( SQLITE_OK != sqlite3_exec(g_db, query, NULL, 0, &err_msg)) { + if (err_msg) { + log_error("SQLite error: %s", err_msg); + sqlite3_free(err_msg); + } else { + log_error("Unknown SQLite error"); + } + return FALSE; + } + + log_debug("Initialized SQLite database: %s", filename); return TRUE; } @@ -67,4 +79,3 @@ log_database_close(void) sqlite3_close(g_log_database); sqlite3_shutdown(); } -