Skip to content

juanique/python-virtuoso

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

###Introduction

This is a Virtuoso wrapper library for python. It wraps the isql-vt shell to perform load and delete data operations and uses the SPARQL endpoint to perform queries.

###Requirements

###Usage

####SPARQL Query

from virtuoso import Virtuoso

#Init the triplestore with the host, username, password, endpoint port and endpoint
#path
triplestore = Virtuoso("localhost", "dba", "mypassword", 8890, "/sparql")

results = triplestore.query("SELECT * WHERE {?s ?p ?o}")
for row in results:
    print row["s"].value, row["p"].value, row["o"].value

####Insert and delete data

from rdflib import Namespace, Literal

graph = "http://my-graph"
ns = Namespace("http://my-name-space.com/#")

#Insert a triple into the triplestore
# <http://my-name-space.com/#user123> <http://my-name-space.com/#user123> "Juan"
triplestore.insert(graph, ns["user123"], ns["name"], Literal("Juan"))

#Deleting the triple just inserted
triplestore.delete(graph, ns["user123"], ns["name"], Literal("Juan"))

#Clean the whole graph
triplestore.clean_graph(graph)

About

A (fast and dirty) virtuoso triplestore wrapper for python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages