'volume' : volume } if len(objects) >= chunk_size: print(f"Running chunk {chunk}") client.insert_document(objects,commit_msg = f"Inserting stock exchange ticker chunk {chunk}") objects = [] chunk+=1 else: objects.append(obj) if not (objects == []): client.insert_document(objects,commit_msg = "Adding initial schema") load_file('indexData.csv') branch = "second" client.create_branch(branch) client.branch = branch load_file('other.csv') print("About to rebase") client.branch = "main" client.rebase(f"{team}/{db}/local/branch/second") print("About to query") client.optimize(f"{team}/{db}") documents = client.query_document({'@type' : 'IndexRecord', 'date' : '2021-07-01'}) print(list(documents))
# TODO: change the team name team = "<TEAM_NAME>" client = WOQLClient("https://cloud.terminusdb.com/"+team) try: client.connect(team=team, use_token=True) client.create_database(db_id, label = "Netflix Graph", description = "Create a graph with Netflix data") except Exception: client.connect(db=db_id, team=team, use_token=True) schema.commit(client, commit_msg = "Adding Netflix Schema") insert_content_data(client, url) contents = client.query_document({"@type" : "Content"}, count=50) insert_user_data(list(contents)) print("\nQUERING DOCUMENTS\n") query_documents(client) print("\nBranches\n") branches(client) # Get the whole commit history: commit_history = client.get_commit_history() print("\nCOMMIT HISTORY\n",commit_history) # Manipulate the commit history print("\nTime Travel\n")
from terminusdb_client import WOQLClient from terminusdb_client.woqlschema import WOQLSchema from terminusdb_client.woqldataframe import result_to_df # For Terminus X, use the following # client = WOQLClient("https://cloud.terminusdb.com/<Your Team>/") # client.connect(db="demo_workshop", team="<Your Team>", use_token=True) client = WOQLClient("http://127.0.0.1:6363/") client.connect(db="getting_started") team_it_raw = client.query_document({"@type": "Employee", "team": "it"}) team_marketing_raw = client.query_document({ "@type": "Employee", "team": "marketing" }) team_it = result_to_df(team_it_raw) team_marketing = result_to_df(team_marketing_raw) team_it_avg = team_it["name"].apply(len).sum() / len(team_it) team_marketing_avg = team_it["name"].apply(len).sum() / len(team_marketing) print(f"Average name length of IT team is {team_it_avg}") print(f"Average name length of Marketing team is {team_marketing_avg}")