Package: nebula2-python-aden
nebula-pythonThis directory holds the Python API for Nebula聽Graph. It is used to connect with Nebula Graph 2.0.Before you startBefore you start, please read this section to choose the right branch for you. In branch v1.0, the API works only for Nebula Graph 1.0. In the master branch, the API works only for Nebula Graph 2.0.The directory structure|--nebula-python
    |
    |-- nebula2                               // client code
    |   |-- fbthrift                          // the fbthrift lib code
    |   |-- common           
    |   |-- data           
    |   |-- graph           
    |   |-- meta           
    |   |-- net                               // the net code for graph client
    |   |-- storage           
    |   |-- Config.py                         // the pool config
    |   |__ Exception.py                      // the define exception
    |           
    |-- examples
    |   |-- GraphClientMultiThreadExample.py  // the multi thread example
    |   |-- GraphClientSimpleExample.py       // the simple example
    |   |__ ScanVertexEdgeExample.py                   
    |
    |-- tests                                 // the test code
    |                      
    |-- setup.py                              // used to install or package
    |                      
    |__ README.md                             // the introduction of nebula2-pythonHow to get nebula2-pythonOption one: clone from GitHubClone from GitHubgitclonehttps://github.com/vesoft-inc/nebula-python.gitcdnebula-pythonInstallsudopython3setup.pyinstallWhen your environment cannot accesspypi, you need to install the following packages manually.pip install -r requirements.txtdev versionpip install -r requirements-dev.txtOption two: using pippipinstallnebula2-python==$versionQuick example to use graph-client to connect graphdfromnebula2.gclient.netimportConnectionPoolfromnebula2.ConfigimportConfig# define a configconfig=Config()config.max_connection_pool_size=10# init connection poolconnection_pool=ConnectionPool()# if the given servers are ok, return true, else return falseok=connection_pool.init([('127.0.0.1',9669)],config)# option 1 control the connection release yourself# get session from the poolsession=connection_pool.get_session('root','nebula')# select spacesession.execute('USE nba')# show tagsresult=session.execute('SHOW TAGS')print(result)# release sessionsession.release()# option 2 with session_context, session will be released automaticallywithconnection_pool.session_context('root','nebula')assession:session.execute('USE nba')result=session.execute('SHOW TAGS')print(result)# close the poolconnection_pool.close()Quick example to use storage-client to scan vertex and edgeYou should make sure the scan client can connect to the address of storage which see fromSHOW HOSTSfromnebula2.mclientimportMetaCache,HostAddrfromnebula2.sclient.GraphStorageClientimportGraphStorageClient# the metad servers's addressmeta_cache=MetaCache([('172.28.1.1',9559),('172.28.1.2',9559),('172.28.1.3',9559)],50000)# option 1 metad usually discover the storage address automaticallygraph_storage_client=GraphStorageClient(meta_cache)# option 2 manually specify the storage addressstorage_addrs=[HostAddr(host='172.28.1.4',port=9779),HostAddr(host='172.28.1.5',port=9779),HostAddr(host='172.28.1.6',port=9779)]graph_storage_client=GraphStorageClient(meta_cache,storage_addrs)resp=graph_storage_client.scan_vertex(space_name='ScanSpace',tag_name='person')whileresp.has_next():result=resp.next()forvertex_datainresult:print(vertex_data)resp=graph_storage_client.scan_edge(space_name='ScanSpace',edge_name='friend')whileresp.has_next():result=resp.next()foredge_datainresult:print(edge_data)How to choose nebula-pythonNebula2-Python VersionNebulaGraph Version2.0.0b12.0.0beta2.0.0rc12.0.0-rc12.0.02.0.0/2.0.12.5.02.5.02.6.02.6.0