Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将参数作为dict传递给tx.run in Neo4j_Python_Neo4j_Neo4j Python Driver - Fatal编程技术网

Python 将参数作为dict传递给tx.run in Neo4j

Python 将参数作为dict传递给tx.run in Neo4j,python,neo4j,neo4j-python-driver,Python,Neo4j,Neo4j Python Driver,我正在尝试编写一个通用函数来接受一个密码查询和一个参数字典,并能够动态运行任何给定的查询。我所拥有的是这样的: def _run_cypher(tx, cypher, params = {}): results = [] tx.run(cypher, parameters=params) 'CREATE INDEX ON :$label(filemd5)' 对于如下所示的查询: def _run_cypher(tx, cypher, params = {}): res

我正在尝试编写一个通用函数来接受一个密码查询和一个参数字典,并能够动态运行任何给定的查询。我所拥有的是这样的:

def _run_cypher(tx, cypher, params = {}):
    results = []
    tx.run(cypher, parameters=params)
'CREATE INDEX ON :$label(filemd5)'
对于如下所示的查询:

def _run_cypher(tx, cypher, params = {}):
    results = []
    tx.run(cypher, parameters=params)
'CREATE INDEX ON :$label(filemd5)'
将参数传递为

params = {'label': label}
我得到这个错误:

Invalid input '$': expected whitespace or a label name (line 1, column 18 (offset: 17))
"CREATE INDEX ON :$label(filemd5)"

要么我做错了,要么在这种情况下,您无法将命名参数的dict传递给tx.run()…有人可以纠正我的错误吗?谢谢

不能将参数用作标签名称

您需要使用所需的标签和安全检查创建自己生成的查询

但是,您可能需要查看apoc插件,这可能会允许这样做