Skip to content

Commit

Permalink
Updated SPARQL endpoint adapter to use auth credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
Kolea Plesco committed Aug 29, 2022
1 parent 24f1486 commit fcb5b77
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions ted_sws/data_manager/adapters/sparql_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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]


Expand Down Expand Up @@ -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)

0 comments on commit fcb5b77

Please sign in to comment.