Support auxiliary graph caches and dont_optimize flag
@@ -140,6 +140,7 @@ class KypherQuery(object):
multi=None,
parameters={},
force=False,
+ dont_optimize=False,
index=None, loglevel=None,
cmd=None,
**kwargs):
@@ -203,7 +204,8 @@ class KypherQuery(object):
limit=limit,
multi=cmd.get('multi_edge', multi),
parameters=cmd.get('parameters', parameters),
- force=cmd.get('force', force))
+ force=cmd.get('force', force),
+ dont_optimize=cmd.get('dont_optimize', dont_optimize))
self.kgtk_query.defer_params = True
state = self.kgtk_query.translate_to_sql()
@@ -374,7 +376,8 @@ class KypherApi(object):
maxcache=None,
loglevel=None,
config=None,
- readonly=False):
+ readonly=False,
+ aux_dbfiles=None):
"""Create a new API object and initialize a number of configuration values.
'graphcache' should be a filename for a Kypher graph cache to create or reuse.
It uses the same default as the --graph-cache option of the 'query' command.
@@ -407,11 +410,15 @@ class KypherApi(object):
'readonly' controls whether the graph cache is opened in read-only mode or not.
For read-only, the graph cache must exist and contain data that is properly indexed.
+
+ 'aux_dbfiles' can be one or more auxiliary DB files which will be attached to the main
+ DB and can be queried in combination with tables in the main DB in read-only mode.
"""
self.config = config or {}
self.graph_cache = graphcache
if graphcache is None:
self.graph_cache = self.get_config('GRAPH_CACHE')
+ self.aux_dbfiles = aux_dbfiles
self.readonly = readonly
self.index_mode = index
if index is None:
@@ -515,7 +522,8 @@ class KypherApi(object):
# don't do this for now, since we get the aliases as keys() which would require further mapping:
#conn.row_factory = sqlite3.Row
self.sql_store = sqlstore.SqliteStore(dbfile=self.graph_cache, conn=conn,
- loglevel=self.loglevel, readonly=self.readonly)
+ loglevel=self.loglevel, readonly=self.readonly,
+ aux_dbfiles=self.aux_dbfiles)
return self.sql_store
def get_lock(self):
@@ -632,6 +640,7 @@ class KypherApi(object):
multi=None,
parameters={},
force=False,
+ dont_optimize=False,
index=None,
loglevel=None,
cmd=None,
@@ -710,6 +719,8 @@ class KypherApi(object):
'force' specifies the value of the --force option in a 'query' command.
+ 'dont_optimize' specifies the value of the --dont-optimize option in a 'query' command.
+
'index' specifies the indexing mode to use for this query which defaults to the number defined during
creation of the API object (just like the --index option of the 'query' command).
@@ -728,7 +739,7 @@ class KypherApi(object):
self, inputs=inputs, doc=doc, name=name, maxcache=maxcache,
query=query, match=match, where=where, opt=opt, owhere=owhere, opt2=opt2, owhere2=owhere2,
with_=with_, wwhere=wwhere, ret=ret, order=order, skip=skip, limit=limit, multi=multi,
- parameters=parameters, force=force, index=index, loglevel=loglevel, cmd=cmd,
+ parameters=parameters, force=force, dont_optimize=dont_optimize, index=index, loglevel=loglevel, cmd=cmd,
**kwargs)
return kypher_query
