python client 路径返回结果中路径为空

session.execute('INSERT VERTEX player(name, age) VALUES '
               '\'Bob\':(\'Bob\', 10), '
               '\'Lily\':(\'Lily\', 9), '
               '\'Tom\':(\'Tom\', 10), '
               '\'Jerry\':(\'Jerry\', 13), '
               '\'John\':(\'John\', 11)')

session.execute('INSERT EDGE like(likeness) VALUES '
                       '\'Bob\'->\'Lily\':(80.0), '
                       '\'Bob\'->\'Tom\':(70.0), '
                       '\'Lily\'->\'Jerry\':(84.0), '
                       '\'Tom\'->\'Jerry\':(68.3), '
                       '\'Bob\'->\'John\':(97.2)')

result = session.execute('FIND ALL PATH FROM \"Bob\" to \"Jerry\" OVER *')
for item in result.rows():
    print(item.values[0].get_pVal())

返回的结果

Path(
    src=Vertex(
        tags=[]),
    steps=[Step(
        dst=Vertex(
            tags=[]),
        type=1,
        name=b'like',
        ranking=0,
        props={}),
    Step(
        dst=Vertex(
            tags=[]),
        type=1,
        name=b'like',
        ranking=0,
        props={})])

怎么看点的id和属性?

你可以参考这个
https://github.com/vesoft-inc/nebula-python/blob/master/example/FormatResp.py
https://github.com/vesoft-inc/nebula-python/blob/master/tests/test_data_from_server.py
你不要用原始的数据结构Path, 用包装过的 PathWrapper

至于结果为空,你用console执行的结果也是为空吗?可以执行下截图出来?

1 个赞

console执行FIND SHORTEST PATH FROM ‘Bob’ to ‘Jerry’ OVER *语句之后 直接卡死了
其他语句都正常

2021/01/08 06:23:47 Loop error, *graph.ExecutionResponse error reading struct: *nebula.DataSet error reading struct: *nebula.Row error reading struct: *nebula.Value error reading struct: *nebula.Path error reading struct: *nebula.Vertex error reading struct: error reading field 1: read tcp 172.18.0.11:35030->172.18.0.9:3699: i/o timeout

你用的服务端版本是多少的?应该是服务端和客户端接口不一致导致的,假如服务端是rc1的,升级下console和python client

11

什么时候nebula-graph有11这个版本

之前用的nebula2-python 2.0.0.post1
官网上写的是2.0.0-alpha
但是找不到nebula2-python 2.0.0-alpha

python 客户端没有发alpha版本,直接发的beta版本,你用的就是beta版本,beta版本和alpha的接口应该是可以互通的,所以你的应该就是服务返回的就是空,至于console,你需要用回alpha版本,但是我建议你更新下版本把,alpha的问题很多被修复了,而且alpha很多功能还不完善。

1 个赞

好的 非常感谢

换了新版本之后 账号密码是啥阿
试了一下 root nebula和user password和不输入都不行

默认是没有开权限的,你把错误截图下。

/ # nebula-console --address=graphd --port=3699
2021/01/08 07:45:46 Error: username or password is empty!
/ # nebula-console -u root -p password --address=graphd --port=3699
2021/01/08 07:45:55 Fail to connect server, dial tcp 172.18.0.7:3699: connect: connection refused
/ # nebula-console -u root -p nebula --address=graphd --port=3699
2021/01/08 07:46:06 Fail to connect server, dial tcp 172.18.0.7:3699: connect: connection refused
/ # nebula-console --address=graphd --port=3699
2021/01/08 08:07:57 Error: username or password is empty!

新版本的端口改了,你再看下docker-compose的readme

还有更新版本后,原来的数据不能用了,你需要重新导入下数据。

连上了
问一下你们alpha beta版本是怎么区分的
我拉最新master分支上的下来还是alpha版本

你是console的master是吗?代码里面的版本号没改。很抱歉,我们尽快改掉。