python - 在 python 中的 Cypher 查询中传递变量

标签 python flask neo4j cypher

我有2个变量

 name='name1234'
 age='21'

和一个 Neo4j 密码查询

query33= 'CREATE (k:user { Username: @name, Userage: '@age' })'

我如何传递这两个变量?

最佳答案

可以通过格式传递:https://docs.python.org/3.4/library/functions.html#format

query33= "CREATE (k:user {{ Username: {name}, Userage: '{age}' }})".format(name='name1234', age=21)
query33
"CREATE (k:user { Username: name1234, Userage: '21' })"

关于python - 在 python 中的 Cypher 查询中传递变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53923898/

相关文章:

python - 异常处理在 python 程序中不起作用

python - 获取 Chef.Exceptions.ChefServerError : Method Not Allowed while creating Role in chef

python - Flask 自定义登录和模板渲染

python - 如何使用 if __name__== '__main__' 在 Linux 和 Windows 上运行 python 应用程序

python - flask 错误处理程序

neo4j - 使用关系属性限制过滤最短路径 Cypher 查询?

neo4j - 多重关系,如连接表 (neo4j)

python - 导入 matplotlib.pyplot 作为 plt 失败

php - 如何在网页中嵌入 Neo4j Graph?

python - 打印任意数量的 float