This skill enables comprehensive interaction with RDF triple stores for querying, inserting, updating, and managing semantic knowledge graph data using SPARQL.
RDF (Resource Description Framework) represents knowledge as triples - the fundamental building block of semantic web:
Alice → knows → BobSPARQL is the standardized query and update language for RDF, enabling complex queries across semantic datasets.
Use this skill when:
json
{
"endpoint": "http://localhost:3030/dataset/sparql",
"update_endpoint": "http://localhost:3030/dataset/update",
"timeout": 30,
"max_retries": 3,
"default_graph": "http://example.com/default"
}
ParameterTypeDefaultDescriptionendpointstringrequiredSPARQL query endpoint URLupdate_endpointstringoptionalSPARQL update endpoint URLtimeoutinteger30Request timeout in secondsmax_retriesinteger3Maximum retry attemptsdefault_graphstringoptionalDefault graph URIusernamestringoptionalAuthentication usernamepasswordstringoptionalAuthentication passwordformatstringjsonResponse format (json, xml)
http://example.com/alicehttp://foaf.com/knows"Alice"@en, 30^^xsd:integerex:Alice foaf:knows ex:Bobsparql
SELECT ?var1 ?var2
WHERE {
?var1 ?var2 ?var3
}
Returns bindings of variables
sparql
CONSTRUCT { ?s ?p ?o }
WHERE { ?s ?p ?o }
Returns RDF triples
sparql
ASK {
?s ?p ?o
}
Returns boolean result
sparql
DESCRIBE ?resource
Returns RDF description of resource
sparql
?subject ?predicate ?object
Matches any triple in the store
sparql
ex:Alice ?predicate ?object
Query properties of specific resource
sparql
?person foaf:knows ?friend .
?friend foaf:name ?name .
Join multiple triple patterns
sparql
SELECT ?person ?name
WHERE {
?person foaf:name ?name
}
sparql
SELECT ?name
WHERE {
?person foaf:name ?name ;
foaf:age ?age
}
sparql
WHERE {
?person foaf:age ?age .
FILTER (?age > 18)
}
sparql
FILTER (CONTAINS(?name, "Alice"))
FILTER (STRSTARTS(?email, "alice@"))
sparql
FILTER (isLiteral(?value))
FILTER (isIRI(?resource))
sparql
SELECT (COUNT(?person) as ?count)
WHERE {
?person rdf:type foaf:Person
}
sparql
SELECT ?department (COUNT(?person) as ?count)
WHERE {
?person foaf:workDepartment ?department
}
GROUP BY ?department
sparql
SELECT (COUNT(?x) as ?c) (SUM(?age) as ?total)
WHERE { ... }
sparql
SELECT ?name ?email
WHERE {
?person foaf:name ?name
OPTIONAL { ?person foaf:email ?email }
}
sparql
WHERE {
{ ?person foaf:knows ?friend }
UNION
{ ?person foaf:colleague ?friend }
}
sparql
ORDER BY ?name
ORDER BY DESC(?age)
sparql
LIMIT 10
OFFSET 20
sparql
?entity rdf:type ex:Person
?entity rdf:type owl:Class
sparql
?entity rdf:type* ex:Animal // Including subclasses
sparql
INSERT DATA {
ex:Alice ex:knows ex:Bob .
ex:Alice foaf:age 30 .
}
sparql
INSERT {
?person foaf:status "active"
}
WHERE {
?person foaf:age ?age .
FILTER (?age > 18)
}
sparql
DELETE DATA {
ex:Alice ex:knows ex:Bob .
}
sparql
DELETE WHERE {
?person foaf:age ?age .
FILTER (?age < 0)
}
sparql
DELETE {
?person foaf:age ?old
}
INSERT {
?person foaf:age ?new
}
WHERE {
?person foaf:age ?old .
BIND (?old + 1 as ?new)
}
sparql
SELECT ?s ?p ?o
FROM NAMED <http://example.com/graph1>
WHERE {
GRAPH <http://example.com/graph1> { ?s ?p ?o }
}
sparql
INSERT DATA {
GRAPH <http://example.com/graph1> {
ex:Alice ex:knows ex:Bob
}
}
sparql
?person foaf:type ex:Person .
?person rdfs:subClassOf ex:Agent
sparql
?book dc:author ?author .
?author foaf:knows ?colleague
sparql
SELECT ?name
WHERE {
SERVICE <http://dbpedia.org/sparql> {
?resource rdfs:label ?name
}
}
sparql
SELECT ?name ?age ?status
WHERE {
?person foaf:name ?name ;
foaf:age ?age
BIND (IF(?age >= 18, "Adult", "Minor") as ?status)
}
sparql
?person foaf:knows{2} ?distant_friend // 2 hops
?resource dc:subject* ?topic // Any hops
ErrorCauseSolutionEndpoint unreachableServer down or wrong URLVerify endpoint URL and server statusInvalid SPARQL syntaxMalformed queryValidate query syntaxQuery timeoutComplex query or large datasetAdd LIMIT, simplify patterns, add FILTERUnauthorizedMissing credentialsAdd authentication headersBad requestInvalid parametersCheck parameter encodingServer errorEndpoint issueCheck endpoint logs
✅ Filter early with FILTER clauses
✅ Use LIMIT to restrict result sets
✅ Avoid expensive joins when possible
✅ Use specific properties instead of wildcards
✅ Create indexes on frequently queried predicates
✅ Use consistent URIs for resources
✅ Apply ontologies consistently
✅ Use named graphs for data organization
✅ Maintain referential integrity
✅ Document ontology extensions
✅ Use transactions for multi-step updates
✅ Validate data before insertion
✅ Use parameterized queries
✅ Handle duplicates appropriately
✅ Log all modifications
✅ Version ontologies
✅ Document classes and properties
✅ Use standard vocabularies (FOAF, Dublin Core, etc.)
✅ Define constraints and restrictions
✅ Maintain semantic consistency
✅ Use compression for large datasets
✅ Index high-cardinality predicates
✅ Monitor query performance
✅ Use CONSTRUCT for large result sets
✅ Batch inserts for better throughput
✅ Use OWL constraints
✅ Enable reasoning when needed
✅ Validate against ontologies
✅ Check cardinality constraints
✅ Maintain type consistency
✅ Follow HTTP URIs standards
✅ Use standard vocabularies
✅ Provide resolvable URIs
✅ Include owl:sameAs links
✅ Support content negotiation
✅ Authenticate connections
✅ Validate SPARQL queries
✅ Use HTTPS for endpoints
✅ Implement access control
✅ Sanitize user input
LibraryPurposerdflibPython RDF librarySPARQLWrapperSPARQL endpoint clientrequestsHTTP clientjsonJSON handling
LibraryPurposeowlrlOWL reasoningpydanticData validationpandasData transformation
bash
pip install rdflib sparqlwrapper requests pydantic
Using this skill enables:
✅ Semantic Integration - Leverage RDF and ontologies for knowledge representation
✅ Interoperability - Work with linked open data and semantic web standards
✅ Complex Queries - SPARQL supports sophisticated graph queries
✅ Reasoning - Enable ontology-based inference
✅ Standards-Based - Build on W3C standards (RDF, OWL, SPARQL)
✅ Scalability - Modern triple stores handle large datasets
✅ Flexibility - Support multiple data formats and serializations
python
connector = RDFStoreConnector()
connector.connect(config)
result = connector.execute_query(sparql_query)
connector.close()
sparql
# Query by type
SELECT ?entity WHERE { ?entity rdf:type ex:Person }
# Query properties
SELECT ?name WHERE { ex:Alice foaf:name ?name }
# Filter results
SELECT ?person WHERE {
?person foaf:age ?age .
FILTER (?age > 18)
}
python
# Insert triples
connector.insert_data(triples)
# Delete triples
connector.delete_data(pattern)
# Update data
connector.update_data(delete_pattern, insert_pattern, where_clause)
python
# Create graph
connector.create_graph(graph_uri)
# Query graph
result = connector.query_graph(graph_uri, sparql_query)
# List graphs
graphs = connector.list_graphs()
Version: 1.0.0
Last Updated: April 12, 2026