【发布时间】:2022-10-17 10:18:29
【问题描述】:
我是 Gremlin 的新手,并尝试使用 gremlin_python 在海王星数据库中执行批量 upsert。
我在google groups 找到了这个解决方案
l = [
[name:'josh',age:29,country:'usa'],
[name:'bar',age:24,country:'usa']];
g.inject(l).
unfold().as('properties').
select('name').as('pName').
coalesce(V().has('name', where(eq('pName'))),
addV('person')).as('vertex').
sideEffect(select('properties').
unfold().as('kv').
select('vertex').
property(select('kv').by(Column.keys), select('kv').by(Column.values)))
并尝试像这样将其改编为 gremlin_python :
l = [
{'name':'josh','age':29,'country':'usa'},
{'name':'bar','age':24,'country':'usa'}];
g.inject(l).\
unfold().as_('properties').\
select('name').as_('pName').\
coalesce(__.V().has('name', __.where(__.eq('pName'))),
addV('person')).as_('vertex').\
sideEffect(select('properties').\
unfold().as_('kv').\
select('vertex').\
property(select('kv').by(Column.keys), select('kv').by(Column.values)))
有以下错误:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-162-c262a63ad82e> in <module>
8 unfold().as_('properties').\
9 select('name').as_('pName').\
---> 10 coalesce(__.V().has('name', __.where(__.eq('pName'))),
11 addV('person')).as_('vertex').\
12 sideEffect(select('properties').\
TypeError: 'GraphTraversal' object is not callable
我认为代码改编可能是错误的。 谁能给我一个关于这里发生了什么的提示?
【问题讨论】:
标签: gremlin amazon-neptune gremlinpython