python
from franz.openrdf.repository import AllegroGraphRepository
repository = AllegroGraphRepository("localhost", 10035, "username", "password")
repository.initialize()
rdf_triple = ("http://example.org/John", "http://example.org/hasAge", "30")
with repository.getConnection() as connection:
connection.addData(rdf_triple)
with repository.getConnection() as connection:
query = "SELECT ?age WHERE { <http://example.org/John> <http://example.org/hasAge> ?age }"
result = connection.executeTupleQuery(query)
for bindingSet in result:
age = bindingSet.getValue("age")
print("John's age: ", age)