Search code examples
graphdb

Python library for GraphDB


Is there a Python library out there for importing TTL files into GraphDB? I.e. Just point it at a file, rather than loop through millions of statements and inserting them individually?


Solution

  • Don't know about a specific python library for this, but you can use the repository statements endpoint to upload your data.

    Something like this seems to work:

    import requests
    
    headers = {
      'Content-Type': 'application/x-turtle',
      'Accept': 'application/json'
    }
    
    with open('sample.ttl', 'rb') as f:
      requests.post('http://localhost:7200/repositories/test/statements', data=f, headers=headers)
    

    If the data is really big you should probably consider either the loadrdf or the preload tools.