Gremlin Python SDK for Azure CosmosDB

断了今生、忘了曾经 提交于 2021-01-29 12:31:04

问题


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.

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

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/en-us/samples/azure-samples/azure-cosmos-db-graph-python-getting-started/azure-cosmos-db-graph-python-getting-started/

[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


回答1:


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());

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.



来源:https://stackoverflow.com/questions/61641745/gremlin-python-sdk-for-azure-cosmosdb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!