+ rv = sqlite3_open(path, &handle);
+ if (rv != SQLITE_OK) {
+ err("fail to connect database err(%d), errmsg(%s)", rv, sqlite3_errmsg(handle));
+ return NULL;
+ }
+
+ rv = sqlite3_busy_handler(handle, _busy_handler, NULL);
+ if (rv != SQLITE_OK) {
+ err("fail to register busy handler err(%d), errmsg(%s)", rv, sqlite3_errmsg(handle));
+ sqlite3_close(handle);
+ return NULL;
+ }
+
+ dbg("connected to %s", path);
+ return handle;
+}
+
+static gboolean remove_handle(Storage *strg, void *handle)
+{
+ int rv = 0;
+
+ if (!handle)
+ return FALSE;
+
+ rv = sqlite3_close(handle);
+ if (rv != SQLITE_OK) {
+ err("fail to close database err(%d)", rv);
+ handle = NULL;
+ return FALSE;
+ }
+
+ dbg("disconnected from database");