+/*
+ * This file is part of mapper
+ *
+ * Copyright (C) 2007 Kaj-Michael Lang
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
#include "config.h"
#include <glib.h>
#include <sqlite3.h>
#include "db.h"
-#include "utils.h"
sqlite3 *_db=NULL;
gchar *_mapper_db=NULL;
return TRUE;
}
+/**
+ * Helper that execs a given prepared sql statment and resets clears bindings.
+ * return TRUE or FALSE depending on success of the query.
+ *
+ */
+gboolean
+db_exec(sqlite3_stmt *sql)
+{
+gint r;
+
+r=sqlite3_step(sql);
+sqlite3_reset(sql);
+sqlite3_clear_bindings(sql);
+
+return (r==SQLITE_OK) ? TRUE : FALSE;
+}
+
/**
* Close the database connection
*
+/*
+ * This file is part of mapper
+ *
+ * Copyright (C) 2007 Kaj-Michael Lang
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
#include <glib.h>
#include <sqlite3.h>
gboolean db_connect(sqlite3 **db, const gchar *mapper_db);
gboolean db_check(sqlite3 *db, const gchar *table);
gboolean db_close(sqlite3 **db);
+gboolean db_exec(sqlite3_stmt *sql);
#endif