Search code examples
python-2.7gremlinjanusgraph

tx().commit() not working in python gremlin


In Python code i am trying to delete vertex from janusgraph and commit thereafter. But the code g.tx().commit() is returning - "exceptions.AttributeError: 'GraphTraversalSource' object has no attribute 'tx'". Am i missing any imports .Please suggest

I have tried without commit but the vertex simply stays there with out returning any error from code

commit works fine while using gremlin console.issue is observed from code

g.tx().commit()

exceptions.AttributeError: 'GraphTraversalSource' object has no attribute 'tx'.


Solution

  • gremlinpython is a Gremlin Language Variant which translates your Gremlin into bytecode and submits that to a remote server for execution. Once on the server, the transaction is considered "managed" in the sense that each requests automatically starts a transaction and then when the request process is complete the server either commits the transaction if successful or rolls it back if there was a failure. As you have found, you can not (and do not need to) call g.tx() from gremlinpython directly.

    Please consider reading through the TinkerPop Introduction documentation for more information.