我是Gremlin的新手,尝试用gremlin_python在海王星db中执行大容量插入。
我在谷歌集团中找到了这个解决方案
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我认为代码修改可能是错误的。有人能告诉我这是怎么回事吗?
发布于 2022-03-09 16:05:07
__.eq('pName')部分应该是statics.eq(PName)。
之后
from gremlin_python import statics
statics.load_statics(globals())__.eq('pName')部分可以是eq('pName')。
请参阅:https://tinkerpop.apache.org/docs/current/reference/#gremlin-python-imports
发布于 2022-10-17 02:18:29
由于我使用了AWS Neptune DB,我最终应用了Neptune Python工具来进行批量插入:它比我们讨论的解决方案要快,但是在使用它时要小心数据类型和映射。(我对BigInts有意见)
以下是库和文档:https://github.com/awslabs/amazon-neptune-tools/tree/master/neptune-python-utils
https://stackoverflow.com/questions/71406191
复制相似问题