def rm_database_terminus_execute(kwargs): # Functional Programming stuffs kwargs = copy.copy(kwargs) client = terminusdb_client.WOQLClient(server_url=kwargs['url']) client.connect(account=kwargs['accountid'], key=kwargs['pass'], user=kwargs['accountid']) client.delete_database(kwargs['dbid'])
def list_database_action(options): # Instantiate Objects client = terminusdb_client.WOQLClient(options.url) WOQLLib_obj = terminusdb_client.WOQLLib() # Generate query for database query_macro = WOQLLib_obj.dbs(None, None) # Execute Query client.connect(account=options.account, key=options.password) db_list = client.query(query_macro) print(db_list)
def add_database_terminus_execute(kwargs): # Functional Programming stuffs kwargs = copy.copy(kwargs) # Query Database and Add New Database client = terminusdb_client.WOQLClient(server_url=kwargs['url']) client.connect(account=kwargs['accountid'], key=kwargs['pass'], user=kwargs['accountid']) client.create_database( kwargs['dbid'], kwargs['accountid'], label=kwargs['label'], # label require otherwise will fail to add DB description=kwargs['desc'], prefixes=kwargs['prefix'], include_schema=kwargs['schema']) return 0
from django.shortcuts import render from rest_framework.views import APIView from rest_framework.response import Response import terminusdb_client as woql from terminusdb_client import WOQLQuery db_id = "student" client = woql.WOQLClient(server_url="https://127.0.0.1:6363", insecure=True) client.connect(key="root", account="admin", user="******") client.db(db_id) class StudentAPIView(APIView): """ Create Student API """ def post(self, request, *args, **kwargs): WOQLQuery().insert("stu002", "scm:student") \ .property("scm:name", request.data['name']) \ .execute(client) # Generate response return Response({'message': 'ok'})
label="v:Bike_Label") ) return inserts def load_csvs(client, csvlist, wrangl, insert): """Load the CSVs as input Parameters ========== client : a WOQLClient() connection csvs : a dict of all csvs to be input """ for url in csvlist: csv = get_csv_variables(url) inputs = WOQLQuery().woql_and(csv, *wrangl) answer = WOQLQuery().when(inputs, insert) answer.execute(client, f"loading {url} into the graph") if __name__ == "__main__": db_id = "pybike" client = woql.WOQLClient(server_url = "http://localhost:6363") client.connect(key="root", account="admin", user="******") existing = client.get_metadata(db_id, client.uid()) if not existing: client.create_database(db_id, accountid="admin", label = "Bike Graph", description = "Create a graph with bike data") else: client.db(db_id) create_schema(client) load_csvs(client, csvs, get_wrangles(), get_inserts())