适用于 Azure CosmosDB 的 Gremlin Python SDK
Gremlin Python SDK for Azure CosmosDB
CosmoDB 和 Gremlin 的 Azure 站点上的文档和 Python[1][2][3] 使用了不良做法 - 大量代码重复和连接字符串以形成查询,而不是使用原生 python.
但是,当尝试使用本机 SDK 时,有一个 2 年前的错误会由于序列化错误而阻止它[4]。
在 CosmosDB 中使用 Gremlin 和 Python 的最佳方式是什么?我应该完全放弃 Gremlin - 如果是这样,替代解决方案是什么?
[2]
https://docs.microsoft.com/en-us/azure/cosmos-db/create-graph-pytho
[3]
https://github.com/Azure-Samples/azure-cosmos-db-python-getting-started
[4]https://github.com/Azure/azure-cosmos-dotnet-v2/issues/439
如您所述,如果没有纯字节码支持here,Python 将 CosmosDB 与 Gremlin 结合使用的情况就不太好。有一些机制可以将字节码转换为脚本表示形式,例如 GroovyTranslator
用于 Java 和 Translator
用于 Java 脚本。例如,在 Java 脚本中你可以这样做:
const script = new Translator('g').translate(g.V().out('created').getBytecode());
然后将该脚本提交给 CosmosDB(Java 的示例是 ). Not great but arguably better than embedding fat strings of Gremlin into your code. Unfortunately, there is no support for this functionality in Python at this time. I've created an issue in JIRA to track it (TINKERPOP-2366 - Python and TINKERPOP-2367 - .NET),因为我已经看到这个问题以不同的形式出现,并且具有合理的一致性。
CosmoDB 和 Gremlin 的 Azure 站点上的文档和 Python[1][2][3] 使用了不良做法 - 大量代码重复和连接字符串以形成查询,而不是使用原生 python.
但是,当尝试使用本机 SDK 时,有一个 2 年前的错误会由于序列化错误而阻止它[4]。
在 CosmosDB 中使用 Gremlin 和 Python 的最佳方式是什么?我应该完全放弃 Gremlin - 如果是这样,替代解决方案是什么?
[2] https://docs.microsoft.com/en-us/azure/cosmos-db/create-graph-pytho
[3] https://github.com/Azure-Samples/azure-cosmos-db-python-getting-started
[4]https://github.com/Azure/azure-cosmos-dotnet-v2/issues/439
如您所述,如果没有纯字节码支持here,Python 将 CosmosDB 与 Gremlin 结合使用的情况就不太好。有一些机制可以将字节码转换为脚本表示形式,例如 GroovyTranslator
用于 Java 和 Translator
用于 Java 脚本。例如,在 Java 脚本中你可以这样做:
const script = new Translator('g').translate(g.V().out('created').getBytecode());
然后将该脚本提交给 CosmosDB(Java 的示例是