[tracker/wip/carlosg/tracker-3.0-api-breaks: 32/95] tracker: Add --database argument to "sql" CLI subcommand
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/tracker-3.0-api-breaks: 32/95] tracker: Add --database argument to "sql" CLI subcommand
- Date: Fri, 14 Feb 2020 13:33:18 +0000 (UTC)
commit 51a6d94cbc09b617c745cb2ffbc8177d0d2247a6
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Dec 21 14:20:58 2019 +0100
tracker: Add --database argument to "sql" CLI subcommand
Make it useful to inspect any database created by Tracker.
src/tracker/tracker-sql.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
---
diff --git a/src/tracker/tracker-sql.c b/src/tracker/tracker-sql.c
index ec02db114..2d9d37f7c 100644
--- a/src/tracker/tracker-sql.c
+++ b/src/tracker/tracker-sql.c
@@ -37,8 +37,13 @@
static gchar *file;
static gchar *query;
+static gchar *database_path;
static GOptionEntry entries[] = {
+ { "database", 'd', 0, G_OPTION_ARG_FILENAME, &database_path,
+ N_("Location of the database"),
+ N_("FILE")
+ },
{ "file", 'f', 0, G_OPTION_ARG_FILENAME, &file,
N_("Path to use to run a query from file"),
N_("FILE"),
@@ -95,20 +100,12 @@ sql_by_query (void)
TrackerDBCursor *cursor = NULL;
GError *error = NULL;
gint n_rows = 0;
- GFile *cache_location, *ontology_location;
+ GFile *db_location;
TrackerDataManager *data_manager;
- gchar *dir;
-
- dir = g_build_filename (g_get_user_cache_dir (), "tracker", NULL);
- cache_location = g_file_new_for_path (dir);
- g_free (dir);
-
- dir = g_build_filename (SHAREDIR, "tracker", "ontologies", "nepomuk", NULL);
- ontology_location = g_file_new_for_path (dir);
- g_free (dir);
- data_manager = tracker_data_manager_new (0, cache_location,
- ontology_location,
+ db_location = g_file_new_for_commandline_arg (database_path);
+ data_manager = tracker_data_manager_new (TRACKER_DB_MANAGER_READONLY,
+ db_location, NULL,
FALSE, 100, 100);
if (!g_initable_init (G_INITABLE (data_manager), NULL, &error)) {
@@ -239,7 +236,9 @@ tracker_sql (int argc, const char **argv)
g_option_context_free (context);
- if (file && query) {
+ if (!database_path) {
+ failed = _("A database path must be specified");
+ } else if (file && query) {
failed = _("File and query can not be used together");
} else {
failed = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]