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

py-brickschema and Oxigraph #84

Open
jansiroky opened this issue Mar 11, 2022 · 4 comments
Open

py-brickschema and Oxigraph #84

jansiroky opened this issue Mar 11, 2022 · 4 comments

Comments

@jansiroky
Copy link

We do have RDFs in the Oxigraph database and we want to use py-brickschema module for processing these data. I do have two questions:
1, I was able to obtain the content of the database using HTTP POST with a SPARQL query. I do have Python string with triplets formatted as CSV, XML, or JSON. How it can be imported into a Graph? Below is a code snippet using XML format that is not working. What is wrong here?

    headers =  {"Accept" : "application/sparql-results+xml", "Content-Type" : "application/x-www-form-urlencoded"}
    query = {"query" : 'select ?s ?p ?o where {  ?s ?p ?o . } limit 1000 '}
    response = requests.post(api_url, data=query, headers=headers)   
    g = Graph(load_brick=True)
    g.parse(data=response.content, format="application/rdf+xml")

2, Is there a way how to directly connect to the remote Oxigraph database from py-brickschema (instead of exporting triples using query as pointed out in 1,)?

@gtfierro
Copy link
Member

Hi @jansiroky --- I didn't see a notification for this, so sorry for the delay in my reply! Let me look into this and get back to you

@jansiroky
Copy link
Author

Hi @gtfierro do you have any solution to this issue? Thanks, Jan

@gtfierro
Copy link
Member

For issue 1, you cannot use the graph.parse method because this is expecting the graph dump rather than the results of a SPARQL query -- they are formatted differently even though they have similar information. You will need to iterate over the triples returned by your SPARQL query and load them into your graph one at a time. Packages like https://github.com/RDFLib/sparqlwrapper/ can help with this

For issue 2, I'm not sure this is possible currently. py-brickschema can use https://pypi.org/project/pyoxigraph/ as a Store for the triples, but requires the underlying graph API to be implemented (.add(), etc) for its functionality to work. Can you give me some more details on what features of py-brickschema you'd like to use on a remote database?

@jansiroky
Copy link
Author

Thank you for the reply.

Issue 1 - we were able to resolve it according to the suggested procedure.
Issue 2 - we do not see this as a priority since we do already have a working solution.

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

2 participants