From 2432b067c10bdf2df9aebf8820ffed811eab9411 Mon Sep 17 00:00:00 2001 From: Amrit Bath Date: Wed, 31 Jul 2024 12:22:14 -0700 Subject: [PATCH] Fix incorrect example This example was printing row without updating its value from the new "res" object. Now, it prints "1 instead of "Valentino Rossi". Additionally, if this script was run multiple times, the results would change. Now we delete the graph's contents so the script returns consistent results. --- index.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.md b/index.md index 69b5805..64ee44c 100644 --- a/index.md +++ b/index.md @@ -45,6 +45,8 @@ db = FalkorDB(host='localhost', port=6379) # Create the 'MotoGP' graph g = db.select_graph('MotoGP') +# Clear out this graph in case you've run this script before. +g.delete() g.query("""CREATE (:Rider {name:'Valentino Rossi'})-[:rides]->(:Team {name:'Yamaha'}), (:Rider {name:'Dani Pedrosa'})-[:rides]->(:Team {name:'Honda'}), @@ -61,7 +63,7 @@ for row in res.result_set: # Query how many riders represent team Ducati ? res = g.query("""MATCH (r:Rider)-[:rides]->(t:Team {name:'Ducati'}) RETURN count(r)""") -print(row[0]) # Prints: 1 +print(res.result_set[0][0]) # Prints: 1 ``` For additional demos please see visit [Demos](https://github.com/FalkorDB/demos).