Ejemplo n.º 1
0
def virtuosotest():
    """ Method for testing basic virtuoso connectivity 
    """
    triplestore = Virtuoso("localhost", "dba", "dba", 8890, "/sparql")

    results = triplestore.endpoint.query("SELECT * WHERE {?s ?p ?o} LIMIT 5")

    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 (cant use triplestore.clean as there's a typo in the wrapper..)
    triplestore.isql.clean_graph(graph)
Ejemplo n.º 2
0
def virtuosotest():
    """ Method for testing basic virtuoso connectivity 
    """
    triplestore = Virtuoso("localhost", "dba","dba", 8890, "/sparql")
    
    results = triplestore.endpoint.query("SELECT * WHERE {?s ?p ?o} LIMIT 5")
       
    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 (cant use triplestore.clean as there's a typo in the wrapper..)
    triplestore.isql.clean_graph(graph)
Ejemplo n.º 3
0
def save_xmlrdf_to_virtuoso(xmlrdf=None, graphIRI=None):
    ''' Function to save data in XML/RDF format into the Virtuoso triplestore.
        If the data should be saved in a named graph, provide a String for the
        graph-name to graphIRI, otherwise data will be saved in the default graph
        
        Returns 0 on failure, 1 on success
    '''
    if (xmlrdf is None):
        #Nothing to add
        return 0

    triplestore = Virtuoso("localhost", "dba", "dba", 8890, "/sparql")
    g = rdflib.Graph()
    g.parse(data=xmlrdf, format="xml")

    graph = graphIRI

    for triple in g.triples((None, None, None)):
        triplestore.insert(graph, triple[0], triple[1], triple[2])

    return 1
Ejemplo n.º 4
0
def save_xmlrdf_to_virtuoso(xmlrdf=None,graphIRI=None):
    ''' Function to save data in XML/RDF format into the Virtuoso triplestore.
        If the data should be saved in a named graph, provide a String for the
        graph-name to graphIRI, otherwise data will be saved in the default graph
        
        Returns 0 on failure, 1 on success
    '''
    if(xmlrdf is None):
        #Nothing to add
        return 0
    
    triplestore = Virtuoso("localhost", "dba","dba", 8890, "/sparql")
    g =  rdflib.Graph()
    g.parse(data=xmlrdf, format="xml")

    graph = graphIRI

    for triple in g.triples((None, None, None)):
        triplestore.insert(graph,triple[0],triple[1],triple[2])

    return 1