Python-Gremlin driver in Cosmos DB

162 Views Asked by At

I'm trying to use the gremlinpython library to connect to Cosmos DB, and it seems like only the async queries are possible.

from gremlin_python.driver import client, serializer
from gremlin_python.process.anonymous_traversal import traversal
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
from gremlin_python.driver import serializer

host = "my_host"
username = "my_username"
pwd = "COSMOS_KEY"

client = client.Client(
    host,
    "g",
    username=username,
    password=pwd)

# This works
callback = client.submit_async("g.V().hasLabel('question')")
callback.result().all().result()

# Does not work
g = traversal().with_remote(client)
g.V().hasLabel("question").to_list()

It is not clear what I'm missing as the only documentation provided by Microsoft is on this page https://learn.microsoft.com/en-us/azure/cosmos-db/gremlin/quickstart-python showing only the first method.

1

There are 1 best solutions below

0
Kelvin Lawrence On

I do not believe that Azure Cosmos DB supports Gremlin Bytecode. When you do something like :

g = traversal().with_remote(client)
g.V().hasLabel("question").to_list()

you are using Gremlin Bytecode.

Please also see this quite old Git issue https://github.com/Azure/azure-cosmos-dotnet-v2/issues/439