Skip to content

Commit f4d0ee1

Browse files
authored
Merge pull request #130 from lanl/pulido/issue129
Pulido/issue129
2 parents 411ad4d + 4e76f1b commit f4d0ee1

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

dsi/backends/sqlite.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,15 @@ def put_artifacts(self, collection, isVerbose=False):
186186

187187
# Returns text list from query
188188
def get_artifacts(self, query, isVerbose=False, dict_return = False):
189-
if query[:6].lower() == "select":
189+
if query[:6].lower() == "select" or query[:6].lower() == "pragma" :
190190
try:
191191
data = self.cur.execute(query).fetchall()
192192
if isVerbose:
193193
print(data)
194194
except:
195195
raise ValueError("Error in get_artifacts handler: Incorrect SELECT query on the data. Please try again")
196196
else:
197-
raise ValueError("Error in get_artifacts handler: Can only run SELECT queries on the data")
197+
raise ValueError("Error in get_artifacts handler: Can only run SELECT or PRAGMA queries on the data")
198198

199199
if dict_return:
200200
query_cols = [description[0] for description in self.cur.description]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#Loading using plugins and backends
2+
from dsi.core import Terminal
3+
4+
'''Example access workflow once database has been generated'''
5+
6+
a=Terminal(debug_flag=True)
7+
a.load_module('backend','Sqlite','back-read', filename='wildfire.db')
8+
a.transload()
9+
cnames = a.artifact_handler(interaction_type='get', query = "PRAGMA table_info(wfdata);")
10+
data = a.artifact_handler(interaction_type='get', query = "SELECT * FROM wfdata;")#, isVerbose = True)
11+
12+
# a.artifact_handler(interaction_type="read")
13+
clist = [i[1] for i in cnames]
14+
dlist = list(data)
15+
print(clist)
16+
print(dlist)
17+
# a.unload_module('backend', 'Sqlite', 'back-write')

0 commit comments

Comments
 (0)