def run(): csvpath = "equinox.csv" key = os.environ['TERMINUSDB_ACCESS_TOKEN'] endpoint = os.environ['TERMINUSDB_ENDPOINT'] team = os.environ['TERMINUSDB_TEAM'] team_quoted = urllib.parse.quote(team) #client = WOQLClient(f"https://cloud.terminusdb.com/{team_quoted}/") if endpoint == 'http://127.0.0.1:6363': client = WOQLClient(f"{endpoint}") else: client = WOQLClient(f"{endpoint}/{team_quoted}/") # make sure you have put the token in environment variable # https://docs.terminusdb.com/v10.0/#/terminusx/get-your-api-key # print(f"key: {key}") use_token = True if key == 'false': use_token = False client.connect(user='******', team=team, use_token=use_token) else: client.connect(team=team, use_token=use_token) # use when not recreating # client.connect(db=dbid,team=team,use_token=use_token) exists = client.get_database(dbid) if exists: client.delete_database(dbid, team=team) client.create_database(dbid, team, label=label, description=description, prefixes=prefixes) schema = infer_schema(csvpath) schema_objects = basic_schema + schema.dump_schema() #print(json.dumps(schema_objects, indent=4)) import_schema(client,schema_objects) objects = load_data(csvpath,schema) # print(json.dumps(objects, indent=4)) import_data(client,objects) # If you need to start over with connections... # delete_relationships(client) connect_polities(client,csvpath)
#!/usr/bin/python3 from terminusdb_client import WOQLClient from terminusdb_client import WOQLQuery as WQ import csv # Place the snippet from TerminusX here: # TerminusX db = "stock_index" client = WOQLClient(endpoint) client.connect(account=team,user=user,key=key) exists = client.get_database(db) if not exists: client.create_database(db, team, "Stock Exchange Index Data", "Data From Indexes", { '@base' : "terminusdb:///stock_index/", '@schema' : "terminusdb:///stock_index/schema#" }, True) schema = [ { '@type' : 'Class', '@id' : 'IndexRecord', '@key' : { '@type' : 'ValueHash' }, 'index' : 'xsd:string', 'date' : 'xsd:date', 'open' : 'xsd:decimal', 'high' : 'xsd:decimal', 'low' : 'xsd:decimal',