Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The simplest way to do this is to transform that graph into <code>ntriples</code> and send it to <code>http://yourhost:port/data/GRAPH_URI</code>. If you do an <code>HTTP POST</code> then the triples will be appended to the existing graph represented by <code>GRAPH_URI</code>. If you do a HTTP PUT then the current graph will be replaced. If the graph does not exist then it will be created no matter if you <code>POST</code> or <code>PUT</code>. </p> <p>Taking this function as example:</p> <pre><code>def assert4s(data,epr,graph,contenttype,flush=False): try: params = urllib.urlencode({'graph': graph, 'data': data, 'mime-type' : contenttype }) opener = urllib2.build_opener(urllib2.HTTPHandler) request = urllib2.Request(epr,params) request.get_method = lambda: ('PUT' if flush else 'POST') url = opener.open(request) return url.read() except Exception, e: raise e </code></pre> <p>If you had the following data:</p> <pre><code>triples = """&lt;a&gt; &lt;b&gt; &lt;c&gt; . &lt;d&gt; &lt;e&gt; &lt;f&gt; . """ </code></pre> <p>You can do the following call:</p> <pre><code>assert4s(triples, "http://yourhost:port/data/", "http://some.org/graph/id", "application/x-turtle") </code></pre> <p><strong>Edit</strong></p> <p>My previous answer assumed you were using the 4s-httpd server. You can start the SPARQL server in 4store with the following command <code>4s-httpd -p PORT kb_name</code>. Once you have this running, you can use the following services for:</p> <ul> <li><a href="http://localhost:port/sparql/" rel="nofollow">http://localhost:port/sparql/</a> to submit queries</li> <li><a href="http://localhost:port/data/" rel="nofollow">http://localhost:port/data/</a> to PUT or POST data files.</li> <li><a href="http://localhost:port/update/" rel="nofollow">http://localhost:port/update/</a> to submit SPARQL updates queries.</li> </ul> <p>The 4store <a href="http://4store.org/trac/wiki/SparqlServer" rel="nofollow">SPARQLServer</a> documentation is quite complete.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload