Skip to content

Commit

Permalink
Merge pull request #130 from lanl/pulido/issue129
Browse files Browse the repository at this point in the history
Pulido/issue129
  • Loading branch information
jpulidojr authored Dec 12, 2024
2 parents 411ad4d + 4e76f1b commit f4d0ee1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dsi/backends/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,15 @@ def put_artifacts(self, collection, isVerbose=False):

# Returns text list from query
def get_artifacts(self, query, isVerbose=False, dict_return = False):
if query[:6].lower() == "select":
if query[:6].lower() == "select" or query[:6].lower() == "pragma" :
try:
data = self.cur.execute(query).fetchall()
if isVerbose:
print(data)
except:
raise ValueError("Error in get_artifacts handler: Incorrect SELECT query on the data. Please try again")
else:
raise ValueError("Error in get_artifacts handler: Can only run SELECT queries on the data")
raise ValueError("Error in get_artifacts handler: Can only run SELECT or PRAGMA queries on the data")

if dict_return:
query_cols = [description[0] for description in self.cur.description]
Expand Down
17 changes: 17 additions & 0 deletions examples/wildfire/wildfire_terminal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#Loading using plugins and backends
from dsi.core import Terminal

'''Example access workflow once database has been generated'''

a=Terminal(debug_flag=True)
a.load_module('backend','Sqlite','back-read', filename='wildfire.db')
a.transload()
cnames = a.artifact_handler(interaction_type='get', query = "PRAGMA table_info(wfdata);")
data = a.artifact_handler(interaction_type='get', query = "SELECT * FROM wfdata;")#, isVerbose = True)

# a.artifact_handler(interaction_type="read")
clist = [i[1] for i in cnames]
dlist = list(data)
print(clist)
print(dlist)
# a.unload_module('backend', 'Sqlite', 'back-write')

0 comments on commit f4d0ee1

Please sign in to comment.