【问题标题】:parameters aren't being read in py2neopy2neo 中未读取参数
【发布时间】:2014-05-02 20:05:18
【问题描述】:

我正在尝试根据节点号进行查询并返回属性列表。以下密码查询在 neo4j 浏览器中有效,但是当我尝试通过 py2neo 传递相同的密码查询时,我得到:

"Expected a property container or number here, but got:91"

其中“91”是我要查询的节点号。

摘自我的代码:

def neighbor_finder(a):
     try:                    
        graph_db = neo4j.GraphDatabaseService(url)                     

        query = neo4j.CypherQuery(graph_db,
         """CYPHER 2.0                         
            MATCH (n)-[r]-(m)            
            WHERE ID(n) = {t}
            WITH collect (Distinct m.size) as sizes, collect (Distinct m.weight) as weights, collect (Distinct m.color) as colors, collect (distinct n.label) as node_
            RETURN sizes, weights, colors, node_                                    
            """)                                                                                                                                     
        result = query.execute(t=a)

        for r in result:
            column = [str(item) for item in r.columns]
            value = [str(item) for item in r.values]                                             
            db_dict={k: v for k, v in zip(column, value)}
            for x, y in db_dict.items():
                print x, y

    except Exception as e:
        print e

【问题讨论】:

    标签: python-2.7 neo4j cypher py2neo


    【解决方案1】:

    您能否提供传递给此函数的a 参数的类型和值的详细信息?没有它,我看不到 py2neo 传递给查询参数的内容。

    【讨论】:

    • 我传入 91 作为参数 - 它应该能够读取任何节点号
    【解决方案2】:

    没有读取参数“a”,因为它需要声明为整数,cypher/py2neo 当前正在将其作为字符串读取。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-30
      • 2018-01-19
      • 2016-05-22
      • 1970-01-01
      • 1970-01-01
      • 2017-05-18
      • 2022-01-08
      • 2018-03-05
      相关资源
      最近更新 更多