if cursor.forward():
print('Find it')
else:
print("Didn't find it")
did the trick, never the less with
print(cursor.current["name"])
it breaks python again. Finally to get the values in the cursor I have to make a double graph call, 1 to know if it exist and other to get the values
cursor=my_object.find(value)
if cursor.forward():
fi_list=my_object.find(value)
for record in cursor:
print("Name: "+str(record[0]['name']))
else:
print ("Didn't find it")
I think it could be optimized. Any help will be appreciated.
If you're expecting zero or one record (with one field) then you can use Graph.evaluate:
>>> g.evaluate("UNWIND [] AS x RETURN x")
>>> g.evaluate("UNWIND [1] AS x RETURN x")
1
If you might return multiple records then you probably want to use Cursor.data:
>>> g.run("UNWIND [] AS x RETURN x").data()
[]
>>> g.run("UNWIND [1] AS x RETURN x").data()
[{'x': 1}]
>>> g.run("UNWIND [1, 2] AS x RETURN x").data()
[{'x': 1}, {'x': 2}]
You can then obviously use this conditionally, since empty lists are coerced to False:
>>> print("something" if g.run("UNWIND [] AS x RETURN x").data() else "nothing")
nothing
>>> print("something" if g.run("UNWIND [1] AS x RETURN x").data() else "nothing")
something