From 1ec8f0eb9169fc3f9ab82b60712a332bf60728bf Mon Sep 17 00:00:00 2001 From: Adrian Negreanu Date: Mon, 16 Oct 2017 17:22:57 +0300 Subject: sqlite3gen: use sqlite3_exec for schema setup executing the multiple statements in the schema, we also get the indeces created. Signed-off-by: Adrian Negreanu --- src/sqlite3gen.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/sqlite3gen.cpp b/src/sqlite3gen.cpp index c37adc0..3495206 100644 --- a/src/sqlite3gen.cpp +++ b/src/sqlite3gen.cpp @@ -733,20 +733,13 @@ static int initializeSchema(sqlite3* db) for (unsigned int k = 0; k < sizeof(schema_queries) / sizeof(schema_queries[0]); k++) { const char *q = schema_queries[k][1]; - // create table - rc = sqlite3_prepare_v2(db, q, -1, &stmt, 0); + char *errmsg; + rc = sqlite3_exec(db, q, NULL, NULL, &errmsg); if (rc != SQLITE_OK) { - msg("failed to prepare query: %s\n\t%s\n", q, sqlite3_errmsg(db)); + msg("failed to execute query: %s\n\t%s\n", q, errmsg); return -1; } - rc = sqlite3_step(stmt); - if (rc != SQLITE_DONE) - { - msg("failed to execute query: %s\n\t%s\n", q, sqlite3_errmsg(db)); - return -1; - } - sqlite3_finalize(stmt); } return 0; } -- cgit v0.12