forked from OrsolaMBorrini/dsORMA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimpl.py
43 lines (33 loc) · 1.49 KB
/
impl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import ModelClasses as mdc
import pandas as pd
# 1) Importing all the classes for handling the relational database
from relationalData_Manager import RelationalDataProcessor, RelationalQueryProcessor
# 2) Importing all the classes for handling RDF database
from graphData_Manager import TriplestoreDataProcessor, TriplestoreQueryProcessor
# 3) Importing the class for dealing with generic queries
from GenericQueryP import GenericQueryProcessor
# Once all the classes are imported, first create the relational
# database using the related source data
rel_path = "relational.db"
rel_dp = RelationalDataProcessor()
rel_dp.setDbPath(rel_path)
rel_dp.uploadData("testData/relational_publications.csv")
rel_dp.uploadData("testData/relational_other_data.json")
# Then, create the RDF triplestore (remember first to run the
# Blazegraph instance) using the related source data
grp_endpoint = "http://127.0.0.1:9999/blazegraph/sparql"
grp_dp = TriplestoreDataProcessor()
grp_dp.setEndpointUrl(grp_endpoint)
grp_dp.uploadData("testData/graph_publications.csv")
grp_dp.uploadData("testData/graph_other_data.json")
# In the next passage, create the query processors for both
# the databases, using the related classes
rel_qp = RelationalQueryProcessor()
rel_qp.setDbPath(rel_path)
grp_qp = TriplestoreQueryProcessor()
grp_qp.setEndpointUrl(grp_endpoint)
# Finally, create a generic query processor for asking
# about data
generic = GenericQueryProcessor()
generic.addQueryProcessor(rel_qp)
generic.addQueryProcessor(grp_qp)