Parameters work everywhere except in the relation specifier block [...]

cypher

(Fruitfulapproach) #1
    def addArrowToDatabase(self, arrow):
        cql = "MATCH (s),(t)\n" \
            "WHERE id(s)={srcid} AND id(t)={tarid}\n" \
            "CREATE (s)-[r:snake {name:name}]->(t)\n" \
            "RETURN id(r)"
        try:
            self.connectToDatabase()
            with self.dbDriver.session() as session:
                id = session.run(cql, parameters={
                                     'snake': arrow.snake_case_def(),
                                     'name' : arrow.name(),
                                     'srcid': arrow.sourceNode().databaseID(),
                                     'tarid': arrow.targetNode().databaseID(),
                                     }).single().value()
            arrow.setDatabaseID(id)
        except Exception as e:
            Error(str(e)).exec_()
            if __debug__:
                raise ef __debug__:
>                 raise e

My cypher query is put together in python. Using braces {..} inside of [...] is not working so how would one specify parameters inside of [...]?


(Michael Hunger) #2

You can use $name which is the newer syntax of parameters

also the "[r:snake {name:{name}}]" not working will rather be a python issue than a Cypher one.


(Fruitfulapproach) #3

Thanks, Michael. I think the code (with your corrections) works now or am about to test it.