Skip to content

Commit fcb5b77

Browse files
author
Kolea Plesco
committed
Updated SPARQL endpoint adapter to use auth credentials
1 parent 24f1486 commit fcb5b77

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

ted_sws/data_manager/adapters/sparql_endpoint.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import rdflib
1717
from SPARQLWrapper import SPARQLWrapper, CSV, JSON, RDF
1818

19+
from ted_sws import config
20+
1921
DEFAULT_ENCODING = 'utf-8'
2022
DEFAULT_RDF_FILE_FORMAT = "n3"
2123

@@ -35,7 +37,12 @@ class SPARQLClientPool(object):
3537
@staticmethod
3638
def create_or_reuse_connection(endpoint_url: str):
3739
if endpoint_url not in SPARQLClientPool.connection_pool:
38-
SPARQLClientPool.connection_pool[endpoint_url] = SPARQLWrapper(endpoint_url)
40+
sparql_wrapper = SPARQLWrapper(endpoint_url)
41+
sparql_wrapper.setCredentials(
42+
user=config.AGRAPH_SUPER_USER,
43+
passwd=config.AGRAPH_SUPER_PASSWORD
44+
)
45+
SPARQLClientPool.connection_pool[endpoint_url] = sparql_wrapper
3946
return SPARQLClientPool.connection_pool[endpoint_url]
4047

4148

@@ -211,4 +218,4 @@ class SPARQLFileEndpoint(SPARQLStringEndpoint):
211218

212219
def __init__(self, rdf_file_path: pathlib.Path):
213220
rdf_content = rdf_file_path.read_text(encoding="utf-8")
214-
super().__init__(rdf_content)
221+
super().__init__(rdf_content)

0 commit comments

Comments
 (0)