我还不熟悉使用Neo4j和Python。我想知道在Python和Neo4j中是否可以使用列表元素作为图节点的属性
我试图创建一个配方节点,但在“createNode”变量中出现错误。我做错什么了
这是我的密码:
# a list containing a list of recipes and their respective information
recipeList = [['Mac and Cheese', 'Anytime', 'Macaroni', 'Terry'], ['Chicken Curry', 'Supper', 'Chicken', 'Anne']]
def print_recipes(self,aList):
with self._driver.session() as session:
recipes = session.write_transaction(self.createRecipeNodes,aList)
print(recipes)
def createRecipeNodes(tx, aRecipeList):
for allRecipes in aRecipeList:
#for recipe in allRecipes:
recipeName = allRecipes[0]
serveTime = allRecipes[1]
mainIngrediant = allRecipes[2]
givenBy = allRecipes[3]
createNode = tx.run("CREATE (theNode:Recipe {recipeName = {recipeName}, serveTime = {serveTime}, mainIngrediant = {mainIngrediant}, givenBy = {givenBy}" ,recipeName=recipeName,serveTime=serveTime,mainIngrediant=mainIngrediant,givenBy=givenBy)
我得到的错误是:
neo4j.exceptions.CypherSyntaxError: Invalid input '=': expected whitespace, comment, ':' or '}' (line 1, column 36 (offset: 35)) "CREATE (theNode:Recipe {recipeName = {recipeName}, serveTime = {serveTime}, mainIngrediant = {mainIngrediant}, givenBy = {givenBy}
提前谢谢
Cypher查询不使用
=
进行属性赋值,而是使用:
相关问题 更多 >
编程相关推荐