diff options
-rw-r--r-- | wqflask/wqflask/database.py | 8 | ||||
-rw-r--r-- | wqflask/wqflask/views.py | 6 |
2 files changed, 13 insertions, 1 deletions
diff --git a/wqflask/wqflask/database.py b/wqflask/wqflask/database.py index 663e2ebf..d2929488 100644 --- a/wqflask/wqflask/database.py +++ b/wqflask/wqflask/database.py @@ -1,6 +1,7 @@ # Module to initialize sqlalchemy with flask import os import sys +from SPARQLWrapper import JSON, SPARQLWrapper from typing import Tuple, Protocol, Any, Iterator from urllib.parse import urlparse import importlib @@ -60,3 +61,10 @@ def database_connection() -> Iterator[Connection]: yield connection finally: connection.close() + + +def sparql_connection(): + """Create a sparql objection that is used to query RDF""" + return SPARQLWrapper( + get_setting("SPARQL_ENDPOINT") + ) diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 8a0bede3..1b34e2f8 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -90,6 +90,7 @@ from base.webqtlConfig import TMPDIR from base.webqtlConfig import GENERATED_IMAGE_DIR from wqflask.database import database_connection +from wqflask.database import sparql_connection import jobs.jobs as jobs @@ -491,7 +492,10 @@ def show_trait_page(): metadata = ( template_vars.dataset.accession_id .bind( - lambda idx: get_dataset_metadata(f"GN{idx}") + lambda idx: get_dataset_metadata( + sparql_connection(), + f"GN{idx}" + ) ) ).data |