client = WOQLClient(server_url) client.connect(user=user, account=account, key=key, db=db) try: client.delete_database(db) except Exception as E: pass client.create_database(db, account, label="Schemaless to Schema", description="Two branch database one with schema", include_schema=False) # Create a schemaless branch client.branch('schemaless') # Switch back to main client.checkout('main') # Create the schema graph client.create_graph("schema", "main", "Adding schema") # Add the schema WQ().woql_and(WQ().doctype("scm:BankAccount").label( "Bank Account").description("A bank account").property( "scm:owner", "xsd:string").label("owner").cardinality(1).property( "scm:balance", "xsd:nonNegativeInteger").label("balance")).execute( client, "Adding bank account object to schema") # Add some data which meets the schema
client.connect(user=user, account=account, key=key, db=db, insecure=True) try: client.delete_database(db) except Exception as E: print(E) client.create_database(db, account, label=db_label, description=db_comment, include_schema=False) for branch in branches: # Load the perties branch client.branch(branch, empty=True) client.checkout(branch) print(f"Importing from {branch}") for f in os.listdir(branch): filename = f'{branch}/{f}' ttl_file = open(filename) contents = ttl_file.read() ttl_file.close() # start the chunk work before = time.time() client.insert_triples("instance", "main", contents, f"Adding {branch} in 200k chunk ({f})") after = time.time()
client.optimize(f'{account}/{db}/_meta') client.optimize(f'{account}/{db}/local/_commits') try: client.delete_database(db) except Exception as E: print(E) client.create_database(db, account, label=db_label, description=db_comment, include_schema=False) client.branch('properties') client.checkout('properties') times = [] directory = 'properties_100k' for f in os.listdir(directory): optimizer(client) filename = f'{directory}/{f}' ttl_file = open(filename) contents = ttl_file.read() ttl_file.close() before = time.time() client.insert_triples("instance", "main", contents, f"Adding properties in 100k chunk ({f})") after = time.time() total = (after - before) times.append(total)
client.create_database(db, account, label=db_label, description=db_comment, include_schema=False) print("##########################################################") print("# #") print( f"# Starting run with optimization == {optimize}{space} #") print("# #") print("##########################################################") print("") # Load the perties branch client.branch('literal_properties') client.checkout('literal_properties') times = [] print(f"Importing literal properties from {literal_properties_directory}") for f in os.listdir(literal_properties_directory): filename = f'{literal_properties_directory}/{f}' ttl_file = open(filename) contents = ttl_file.read() ttl_file.close() # start the chunk work before = time.time() if optimize == True: optimizer(client) client.insert_triples("instance", "main", contents, f"Adding literal properties in 100k chunk ({f})")
'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))
client.connect(user=user, account=account, key=key, db=db) new_db = "DBPedia_squash" client.remote_auth({"type": "basic", "user": user, "key": key}) client.clonedb( { "remote_url": f"{server_url}/{user}/{db}", "comment": "Squash test", "label": "Squash test" }, new_db) new_db = "DBPedia_squash" client = WOQLClient(server_url) client.remote_auth({"type": "basic", "user": user, "key": key}) client.connect(user=user, account=account, key=key, db=new_db) client.branch("types") client.checkout("types") client.pull({"remote": "origin", "remote_branch": "types"}) client.branch("properties") client.checkout("properties") client.pull({"remote": "origin", "remote_branch": "properties"}) client.checkout('main') # Rebase valid data to schema branch client.rebase({ "rebase_from": f'{user}/{new_db}/local/branch/types', "author": user, "message": "Merging types into main" })