#!/usr/bin/python3 from terminusdb_client import WOQLClient from terminusdb_client import WOQLQuery server_url = "https://127.0.0.1:6363" client = WOQLClient(server_url) client.connect(user="******", account="admin", key="root", db="bike") client.delete_database("bike") client.create_database("bike","admin",label="Bikes", description="description") query = WOQLQuery().get( WOQLQuery().woql_as("Start station","v:Start_Station") .woql_as("End station", "v:End_Station") .woql_as("Start date", "v:Start_Time") .woql_as("End date", "v:End_Time") .woql_as("Duration", "v:Duration") .woql_as("Start station number", "v:Start_ID") .woql_as("End station number", "v:End_ID") .woql_as("Bike number", "v:Bike") .woql_as("Member type", "v:Member_Type") ).post("bike_csv") result = client.query(query, "This is a commit string", {'bike_csv' : '/home/gavin/tmp/bike_tutorial.csv'})
# Connect to the server server_url = "https://127.0.0.1:6363" db = "dbpedia_1" user = "******" account = "admin" key = "root" client = WOQLClient(server_url) client.connect(user=user, account=account, key=key, db=db) # Example of a single hop query = WOQL().limit( 1, WOQL.woql_and( WOQL().path("doc:Whitesnake", "scm:bandMember", "v:Member", "v:Path"), )) result = client.query(query) print(f"Band member: {result['bindings'][0]['Member']}") query = WOQL().limit( 1, WOQL.woql_and( WOQL().path("doc:Whitesnake", "scm:bandMember,scm:birthPlace", "v:Place", "v:Path"), )) result = client.query(query) print(result['bindings'][0]) query = WOQL().limit( 3, WOQL().select("v:P", "v:Result").woql_and( WOQL().path( "doc:Whitesnake",
#!/usr/bin/python3 from terminusdb_client import WOQLClient from terminusdb_client import WOQLQuery as WQ server_url = "https://127.0.0.1:6363" client = WOQLClient(server_url) client.connect(user="******", account="admin", key="root", db="bike") test3 = WQ().select("v:Time", "v:Message").using("_commits").woql_and( WQ().order_by("v:Time", "v:Message", order=["desc", "asc"]).woql_and( WQ().triple("v:A", "ref:commit_timestamp", "v:Time"), WQ().triple("v:A", "ref:commit_message", "v:Message"))) print(client.query(test3))
key = "root" db = "roster" repository = "local" label = "Roster CSV Example" description = "An example database for playing with bank accounts" client = WOQLClient(server_url) client.connect(user=user, account=account, key=key, db=db) #client.delete_database(db) try: client.create_database(db,account,label=label, description=description, include_schema=None) except Exception as E: pass query = WQ().woql_and( WQ().get(WQ().woql_as("Name","v:Name") .woql_as("Registration_Date", "v:Date") .woql_as("Paid", "v:Paid") ).post('roster.csv'), WQ().idgen("doc:RosterRecord",["v:Name","v:Date","v:Paid"],"v:ID"), WQ().add_triple("v:ID","scm:name","v:Name"), WQ().add_triple("v:ID","scm:date","v:Date"), WQ().add_triple("v:ID","scm:paid","v:Paid")) client.query(query, "Adding Roster Data", {'roster.csv' : '/home/gavin/tmp/roster.csv'} )
#!/usr/bin/python3 import os import time from terminusdb_client import WOQLClient from terminusdb_client import WOQLQuery as WQ server_url = "https://127.0.0.1:6363" db = "DBPedia_squash" user = "******" account = "admin" key = "root" client = WOQLClient(server_url) client.connect(user=user, account=account, key=key, db=db) # client.branch("squash", empty=True) client.checkout("squash") query = WQ().select().woql_and( WQ().using(f"{account}/{db}").triple("v:X","v:Y","v:Z"), WQ().add_triple("v:X","v:Y","v:Z")) client.query(query, "Squash commit")
# openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout localhost.key -out localhost.crt server_url = "https://127.0.0.1:6363" db = "woql" user = "******" account = "admin" key = "root" client = WOQLClient(server_url, insecure=True) client.connect(user=user, account=account, key=key, db=db, insecure=True) query = WQ().triple("v:X", "v:Y", "v:Z").to_dict() print(query) # Just stick the query in there... WQ().update_object(query).execute(client) print("Inserted query") # Instead give the query a name to aid retrieval query['@id'] = 'doc:my_triple_query' WQ().update_object(query).execute(client) print("Inserted named query") # Get the object back results = WQ().read_object('doc:my_triple_query', "v:Query").execute(client) my_triple_query = results['bindings'][0]['Query'] print(f"And here it is: {my_triple_query}") results = client.query(my_triple_query)['bindings'] print(f"And results are us looking at ourselves: {results}")
#!/usr/bin/python3 from terminusdb_client import WOQLClient from terminusdb_client import WOQLQuery as WQ server_url = "https://127.0.0.1:6363" db = "foo" user = "******" account = "admin" key = "root" client = WOQLClient(server_url) client.connect(user=user, account=account, key=key, db=db) try: client.create_database(db, account, label="foo", description="foo and bar, together again") except Exception as E: print(E) [x, y, z] = WQ().vars("x", "y", "z") query = WQ().get(WQ().woql_as(x).woql_as(y).woql_as(z)).file( "/home/gavin/dev/terminus-server/terminus-schema/api.owl.ttl", {"type": "turtle"}) client.query(query)