gpt4 book ai didi

python - 适用于 Azure CosmosDB 的 Gremlin Python SDK

转载 作者:行者123 更新时间:2023-12-02 08:30:04 24 4
gpt4 key购买 nike

Azure 站点上的 CosmoDB、Gremlin 和 Python[1][2][3] 文档使用了不好的做法 - 大量代码重复和连接字符串来形成查询,而不是使用 native Python。

但是,当尝试使用 native SDK 时,存在一个 2 年前的错误,由于序列化错误而无法使用[4]。

将 Gremlin 和 Python 与 CosmosDB 结合使用的最佳方式是什么?我应该完全放弃 Gremlin - 如果是这样,替代解决方案是什么?

[1] https://learn.microsoft.com/en-us/samples/azure-samples/azure-cosmos-db-graph-python-getting-started/azure-cosmos-db-graph-python-getting-started/

[2] https://learn.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 与 Gremlin 一起使用 CosmosDB 的故事并不是那么好。有一些机制可以将字节码转换为脚本表示形式,例如用于 Java 的 GroovyTranslator 和用于 Javascript 的 Translator。例如,在 Javascript 中你可以这样做:

const script = new Translator('g').translate(g.V().out('created').getBytecode());

然后将该脚本提交到 CosmosDB(Java 的示例为 here )。不是很好,但可以说比在代码中嵌入 Gremlin 的胖字符串更好。不幸的是,目前 Python 中不支持此功能。我在 JIRA 中创建了一个问题来跟踪它( TINKERPOP-2366 - Python 和 TINKERPOP-2367 - .NET),因为我看到这个问题以不同的形式出现,并且具有合理的一致性。

关于python - 适用于 Azure CosmosDB 的 Gremlin Python SDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61641745/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com