Package: kgbase
KgbaseInstallationpip install kgbaseAuthenticationTo import library.from kgbase import QueryTo authenticate:q=Query()q.login(username='Your username',password='Your password')You must first signup from kgbase website. Your password must not be shared or exposed via publicly accessible resources (such as browser client-side scripting).To use a proxy:proxies={"http":"http://10.10.1.10:3128","https":"http://10.10.1.10:1080",}q=Query(proxies=proxies)To ignore verifying the SSL certficate:q=Query(verify=False)To get user state:q.get_user_state()To logout:q.logout()ProjectsTo get all public projects:q.get_public_projects()To get all team projects:q.get_team_projects()To get favorite projects:q.get_favorite_projects()To get my projects:q.get_user_projects()To create project:q.create_project(name='electronic devices',is_public=True,)TheprojectIdis returned from response. You need to knowprojectIdwhen you update or detroy project.{"ok":true,"project":{"uuid":"a0406c6d-122a-4ff2-af7f-976ba5cbca01","graphqlId":"Project/1509","projectId":"ctx-M53lgnjpCkc_plt0lqo","...":"..."}}To get project state:q.get_project_state(project_id='ctx-M53lgnjpCkc_plt0lqo')To update project:result=q.update_project(project_id='ctx-M53lgnjpCkc_plt0lqo',name='electronic devices',is_public=False)To destroy project:q.destroy_project(project_id='ctx-M53lgnjpCkc_plt0lqo')TableTo create table:q.create_table(project_id='ctx-M53pLqASSUmxj5yU7LO',display_name='Product',description='Product Description')ThetableIdis returned from the response. You need to knowtableIdwhen you update or delete table.{"ok":true,"tableId":"tab-M53nDu1y1SXMVA_ny97"}To update table:q.update_table(project_id='ctx-M53lgnjpCkc_plt0lqo',table_id='tab-M53nDu1y1SXMVA_ny97',display_name='Smartphones',description='Smartphones manufacurer and model name',)To delete table:q.delete_table(project_id='ctx-M53lgnjpCkc_plt0lqo',table_id='tab-M53nDu1y1SXMVA_ny97')ColumnTo create column:q.create_column(project_id='ctx-M53lgnjpCkc_plt0lqo',table_id='tab-M53nDu1y1SXMVA_ny97',display_name='company',data_type='text')Thedata_typeshould be one oftext,number,boolean,url,date,date_added,date_udated,auto_id,link_one,link_many.You can specify prefix forauto_idcolumn using optionaldata_formatproperty.ThecolumnIdis returned from the response. You need to knowcolumnIdwhen you update or delete column.{"ok":true,"columnId":"col-1"}To createlink_oneorlink_manycolumn:result=q.create_column(project_id='ctx-M53lgnjpCkc_plt0lqo',table_id='tab-M53nDu1y1SXMVA_ny97'display_name='manufacturer',data_type='link_one',linked_table='tab-dfj23eijSFdfewf')To update column:q.update_column(project_id='ctx-M53pLqASSUmxj5yU7LO',table_id='tab-M53pRIARajeAYTwPIAN',column_id='col-1',display_name='price',data_type='number',)To update column to link to table:q.update_column(project_id='ctx-M53pLqASSUmxj5yU7LO',table_id='tab-M53pRIARajeAYTwPIAN',column_id='col-2',display_name='product',data_type='link_many',linked_table='tab-dfj23eijSFdfewf')To delete column:q.delete_column(project_id='ctx-M53pLqASSUmxj5yU7LO',table_id='tab-M53pRIARajeAYTwPIAN',column_id='col-1',)VertexTo create vertex:q.create_vertex(project_id='ctx-M53pLqASSUmxj5yU7LO',table_id='tab-M53pRIARajeAYTwPIAN',values={'col-0':'Google',# text'col-1':10.5,# number'col-2':False,# boolean'col-3':'https://google.com',# url'col-4':datetime.datetime.today()# date# 'col-5'     # date_added},edges=[])Note that you don't have to setdate_added,date_updatedandauto_idtype columns when creating vertex since values are set automatically. Alsocolumn_idsandvalueslists should have same size, and each value in list should match with each data type of columns that you defined before.ThevertexIdis returned from the result. You need to knowvertexIdwhen you update or delete vertex.{"ok":true,"vertex":{"id":"row-M53tT_jTviJ50qyzgsL","label":"tab-M53pRIARajeAYTwPIAN","values":[{"key":"col-1","value":"Google"},{"key":"col-2","value":"Pixel 3A"}],"contextId":null}}To create vertex linking to another table's vertex:q.create_vertex(project_id='ctx-M57S8onUVXwdNMRgHPf',table_id='tab-M57wxxBqH0D7aKgYhhH',values={'col-0':'Apple7','col-1':True,'col-2':''},edges=[("column3","row-M587jZETRpuCBIXUfw6"),("column3","row-M58Ac6n8CjPhqp8-u7M")])Theedgesis a list of tuples which includesColumn Labeland avertexIdthat is linked to.To update vertex:q.update_vertex(project_id='ctx-M53pLqASSUmxj5yU7LO',table_id='tab-M53pRIARajeAYTwPIAN',vertex_id='row-M53tT_jTviJ50qyzgsL',values={'col-1':'Google','col-2':'Pixel 3'},edges=[])To create edge to existing vertex:result=q.update_vertex(project_id='ctx-M57S8onUVXwdNMRgHPf',table_id='tab-M57wxxBqH0D7aKgYhhH',vertex_id='row-M588L2W5S9WZJ5t2Spn',values={'col-0':'Google','col-1':True,'col-2':''},edges=[("column3","row-M587jZETRpuCBIXUfw6"),("column3","row-M58A84uaVMbCC16pSUA")])To delete vertex:q.delete_vertex(project_id='ctx-M53pLqASSUmxj5yU7LO',table_id='tab-M53pRIARajeAYTwPIAN',vertex_id='row-M53tT_jTviJ50qyzgsL',)SchemaTo get schema of project:q.get_schema(project_id='ctx-M53lgnjpCkc_plt0lqo')You can see tables and columns belonging to the project.{"tables":[{"tableId":"tab-M53lgnpTXtQhMqMBXHH","displayName":"Table 1","columns":[],"config":null}],"links":[]}GraphTo get vertices:q.get_graph(project_id='ctx-M53zulrvmCoNnP7PMEU',table_id='tab-M53zumOvT3xKmqkIB_X',filters=[],offset=0,limit=50)To add filtering:q.get_graph(project_id='ctx-M53zulrvmCoNnP7PMEU',table_id='tab-M53zumOvT3xKmqkIB_X',filters=[{"property":"col-2","predicate":"=","value":"apple"}],offset=0,limit=50)To add group by and aggregations:q.summarize_graph(project_id='ctx-M53zulrvmCoNnP7PMEU',table_id='tab-M53zumOvT3xKmqkIB_X',filters=[{"property":"col-2","predicate":"=","value":"apple"}],groups=[{"property":"col-2"}],aggregations=[{"property":"col-1","function":"sum"}],offset=0,limit=50)Thefunctionshould be one ofcount,sum,mean,max,min.Bulk UploadTo upload csv file:q.bulk_upload(project_id='ctx-M57S8onUVXwdNMRgHPf',table_id='tab-MK09gSNWBtZ-g2iLW8-',filepath='/Users/sangwonseo/Downloads/company1.csv',column_ids=['col-0','col-1','col-2'],configs={'countSkipRows':0,'hasHeader':False,'dropEmpty':False})Note that csv files should follow Amazon neptune csv format. For more details, please refer to the documentation.https://docs.aws.amazon.com/neptune/latest/userguide/bulk-load-tutorial-format-gremlin.htmlFor more details about KgbasePlease visithttps://kgbase.com/pages/learnIf you are interested in Kgbase demoPlease request demo athttps://kgbase.com/pages/request-demoIf you have any questionsPlease email atcustomersuccess@thinknum.comLicenseMIT