From fcb5b7740ea44f7fd95b713dd2da2e2a212d262e Mon Sep 17 00:00:00 2001 From: Kolea Plesco Date: Mon, 29 Aug 2022 23:58:00 +0300 Subject: [PATCH] Updated SPARQL endpoint adapter to use auth credentials --- ted_sws/data_manager/adapters/sparql_endpoint.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ted_sws/data_manager/adapters/sparql_endpoint.py b/ted_sws/data_manager/adapters/sparql_endpoint.py index ddb357977..88b43c1d8 100644 --- a/ted_sws/data_manager/adapters/sparql_endpoint.py +++ b/ted_sws/data_manager/adapters/sparql_endpoint.py @@ -16,6 +16,8 @@ import rdflib from SPARQLWrapper import SPARQLWrapper, CSV, JSON, RDF +from ted_sws import config + DEFAULT_ENCODING = 'utf-8' DEFAULT_RDF_FILE_FORMAT = "n3" @@ -35,7 +37,12 @@ class SPARQLClientPool(object): @staticmethod def create_or_reuse_connection(endpoint_url: str): if endpoint_url not in SPARQLClientPool.connection_pool: - SPARQLClientPool.connection_pool[endpoint_url] = SPARQLWrapper(endpoint_url) + sparql_wrapper = SPARQLWrapper(endpoint_url) + sparql_wrapper.setCredentials( + user=config.AGRAPH_SUPER_USER, + passwd=config.AGRAPH_SUPER_PASSWORD + ) + SPARQLClientPool.connection_pool[endpoint_url] = sparql_wrapper return SPARQLClientPool.connection_pool[endpoint_url] @@ -211,4 +218,4 @@ class SPARQLFileEndpoint(SPARQLStringEndpoint): def __init__(self, rdf_file_path: pathlib.Path): rdf_content = rdf_file_path.read_text(encoding="utf-8") - super().__init__(rdf_content) + super().__init__(rdf_content) \ No newline at end of file