Created
November 29, 2013 15:50
-
-
Save jindrichmynarz/7707643 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#-*- coding:utf-8 -*- | |
import requests | |
from requests.auth import HTTPDigestAuth | |
def crud(graphStoreEndpoint, verb, graph, payload, auth): | |
function = { | |
"POST" : requests.post, | |
"PUT" : requests.put, | |
"DELETE" : requests.delete, | |
}[verb] | |
response = function( | |
graphStoreEndpoint, | |
data = payload, | |
params = {"graph" : graph}, | |
auth = auth | |
) | |
return response | |
def main(): | |
graphStoreEndpoint = "http://localhost:8890/sparql-graph-crud-auth" | |
username = "dba" | |
password = "dba" | |
auth = HTTPDigestAuth(username, password) | |
namedGraph = "http://example.com" | |
payload = """ | |
@prefix ex: <http://example.com/> . | |
ex:A ex:B ex:C . | |
""" | |
response = crud(graphStoreEndpoint, "PUT", namedGraph, payload, auth) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment