key = "root" client = WOQLClient(server_url) client.connect(user=user, account=account, key=key, db=db) try: client.delete_database(db) except Exception as E: print(E) client.create_database(db,account,label=f"{db_label}", include_schema=False, description=f"All DBPedia {db} data") times = [] for f in os.listdir(directory): 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 persondata in 100k chunk ({f})") after = time.time() total = (after - before) times.append(total) print(f"Update took {total} seconds") print(times)
label="WordNet", description="WordNet in TerminusDB", include_schema=False) except: pass times = [] directory = 'wordnet_chunks' for f in os.listdir(directory): filename = f'{directory}/{f}' ttl_file = open(filename) contents = ttl_file.read() ttl_file.close() before = time.time() print(f"Loading WordNet in chunks ({f})") client.insert_triples("instance", "main", contents, f"Adding WordNet in chunks ({f})") after = time.time() total = (after - before) times.append(total) print(f"Update took {total} seconds") print(f"Squashing main") before = time.time() client.checkout("main") result = client.squash('Squash commit of properties and types') after = time.time() total = (after - before) print(f"Squash took {total} seconds") commit = result['api:commit'] print(f"Branch reset to {commit}")
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) print(f"Update took {total} seconds") print(times) # Branch from 'main' to 'types' client.checkout('main') client.branch('types') client.checkout('types') times = [] directory = 'instance_100k' for f in os.listdir(directory): optimizer(client) filename = f'{directory}/{f}'
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() total = (after - before) print(f"Update took {total} seconds") for branch in branches: print(f"Rebasing {branch}") client.checkout('main') before = time.time() client.rebase({ "rebase_from": f'{user}/{db}/local/branch/{branch}', "author": user, "message": f"Merging {branch} into main" }) after = time.time()
#!/usr/bin/python3 from terminusdb_client import WOQLClient from terminusdb_client import WOQLQuery as WQ server_url = "https://127.0.0.1:6363" db = "places" db_label = "Places" db_comment = "All DBPedia places (GeoNames)" user = "******" account = "admin" key = "root" filename = "geonames_links_en.ttl" commit_comment = "Adding all geonames" client = WOQLClient(server_url) client.connect(user=user, account=account, key=key, db=db) try: client.delete_database(db) except Exception as E: print(E) client.create_database(db, account, label=db_label, description=db_comment) ttl_file = open(filename) contents = ttl_file.read() ttl_file.close() client.insert_triples("instance", "main", contents, commit_comment)