Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update a property value without adding an additional value, in gremlin_python

In the docs under Updating a Vertex Property, it is mentioned that one can "update a property value without adding an additional value to the set of values" by doing
g.V('exampleid01').property(single, 'age', 25)

In gremlin_python, I am unable to run a query like the above.
I get the error:

update_prop_overwrite = g.V().hasLabel('placeholder-vertex').property(single,'maker','unknown').next()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'single' is not defined 

How can I resolve this so that I can replace a Vertex property value in Neptune?
Without single the query will append the new property value to the property key if a value exists already.

like image 796
cryanbhu Avatar asked Jun 11 '26 05:06

cryanbhu


1 Answers

You need to be sure to import single which is seen here in the code and can be imported with:

from gremlin_python.process.traversal import Cardinality

however TinkerPop documentation recommends importing all such classes with:

statics.load_statics(globals())

You can read more about that here.

like image 113
stephen mallette Avatar answered Jun 16 '26 20:06

stephen mallette