适用于Azure CosmosDB的Gremlin Python SDK [英] Gremlin Python SDK for Azure CosmosDB

查看:73
本文介绍了适用于Azure CosmosDB的Gremlin Python SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Azure网站上有关CosmoDB&的文档格林姆&Python [1] [2] [3]使用错误的做法-大量的代码重复和连接字符串以形成查询,而不是使用本机python.

The documentation on the Azure site for CosmoDB & Gremlin & Python[1][2][3] use bad practices - tons of code duplication and concatenating strings to form queries, rather than using native python.

但是,当尝试使用本机SDK时,由于序列化错误[4],有2年的历史使其无法使用.

However, when trying to use the native SDK, there's a 2 year old bug that prevents it due to serialization errors[4].

使用Gremlin&的最佳方法是什么?使用CosmosDB的Python吗?我是否应该完全放弃格雷姆林-如果是,替代解决方案是什么?

What's the best way to use Gremlin & Python with CosmosDB? Should I give up on Gremlin altogether - and if so, what's the alternative solution?

[1] https://docs.microsoft.com/zh-cn/samples/azure-samples/azure-cosmos-db-graph-python-getting-started/azure-cosmos-db-graph-python-getting-started/

[2] https://docs.microsoft.com/zh-我们/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

推荐答案

如您所述,没有纯字节码支持此处关于使用Gremlin在CosmosDB中使用Python的故事不是很好.有一些机制可以将字节码转换为脚本表示形式,例如Java的 GroovyTranslator 和Javascript的 Translator .例如,在Javascript中,您可以执行以下操作:

Without pure bytecode support as you noted here the story for Python usage for CosmosDB with Gremlin is not so good. There are some mechanisms for translating bytecode to script representations like GroovyTranslator for Java and Translator for Javascript. For example, in Javascript you could do:

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

,然后将该脚本提交给CosmosDB(Java的示例是此处).虽然不怎么好,但是可以说比将Gremlin繁琐的字符串嵌入到您的代码中更好.不幸的是,目前在Python中不支持此功能.我已经在JIRA中创建了一个问题来对其进行跟踪( TINKERPOP-2366 -Python和 TINKERPOP-2367 -.NET),因为我已经看到了这个问题以合理的一致性以不同的形式出现.

and then submit that script to CosmosDB (example for Java is here). 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) as I've seen this question come up in different forms with reasonable consistency.

这篇关于适用于Azure CosmosDB的Gremlin Python SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆