Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find triples is not working using sparqlwrapper and fuseki server #2

Open
terence-coudert opened this issue Feb 21, 2025 · 1 comment
Assignees

Comments

@terence-coudert
Copy link
Collaborator

This code raise a TypeError

from datadocweb.datadoc import DataDoc, Triplestore


url = 'https://physmetfuseki.azurewebsites.net'
database = 'test-tem'
d = DataDoc()
d.store = Triplestore(
    backend='sparqlwrapper',
    base_iri=f'{url}/{database}',
    update_iri=f'{url}/{database}/update',
    username='*****',
    password='*****'
)
d.bind(pm='https://www.ntnu.edu/physmet/data#')
table = d.find(typ='pm:BrightFieldImage', fmt='table')
print(table)
@francescalb
Copy link
Collaborator

Hi, the Fuseki did not like the rdfxml query format, so I changed it in the PR347 in Tripper.

After that I can now query the physmet fuseki as follows:

from tripper import Triplestore, Literal
from tripper.datadoc import search_iris, load_dict
from tripper.datadoc.tabledoc import TableDoc
import keyring
import json

# You would have to set the credentials in your system's keyring beforehand.
username = keyring.get_password("PhysMet_fuseki", "username")
password = keyring.get_password("PhysMet_fuseki", "password")

url = 'https://physmetfuseki.azurewebsites.net'
database = 'test-tem'

ts = Triplestore(
        backend="sparqlwrapper",
        base_iri=f'{url}/{database}',
        username=username,
        password=password,
        update_iri=f'{url}/{database}/update',
        )

ts.bind("pm","https://www.ntnu.edu/physmet/data#")

datasets = search_iris(ts, type = "dataset")

table = TableDoc.fromdicts([load_dict(ts, iri) for iri in datasets])

table.write_csv('data.csv')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants