Skip to content

Error when using a transaction #135

Description

@OrangeBoreal

When committing or rolling back from a transaction, subsequent calls to the client result in a TransactionException :

from neo4jrestclient import client
import os
c = client.GraphDatabase(url=os.environ["NEO4J_URL"])
res = c.query("MATCH (n:Person) WHERE n.name = 'Carol' RETURN n") assert res.get_response()["data"][0][0]["data"] == {"name": "Carol"}

with c.transaction(for_query=True) as t:
    c.query("MATCH (n:Person) WHERE n.name = 'Carol' RETURN n")
    t.rollback()  # or commit()

c.query("MATCH (n:Person) WHERE n.name = 'Carol' RETURN n")
TransactionException                      Traceback (most recent call last)
<ipython-input-16-c750d86ca4cf> in <module>()
      9     t.commit()
     10 
---> 11 c.query("MATCH (n:Person) WHERE n.name = 'Carol' RETURN n")

.../code/neo4j-rest-client/neo4jrestclient/client.pyc in query(self, q, params, returns, data_contents, tx)
    210                 self._cypher, self._auth, q=q, params=params,
    211                 types=types, returns=returns, data_contents=data_contents,
--> 212                 tx=tx
    213             )
    214             if tx is not None and tx.id in self._transactions:

.../code/neo4j-rest-client/neo4jrestclient/query.pyc in __init__(self, cypher, auth, q, params, types, returns, lazy, data_contents, tx)
    322             tx.append(q=self.q, params=self.params, returns=self._returns,
    323                       data_contents=data_contents, obj=self)
--> 324             tx.execute()
    325         elif not lazy:
    326             self._get_elements()

.../code/neo4j-rest-client/neo4jrestclient/query.pyc in execute(self)
    937         if not self.url_tx:
    938             self._begin()
--> 939         results = self._execute(self.url_tx, results=True)
    940         self.finished = False
    941         return results

.../code/neo4j-rest-client/neo4jrestclient/query.pyc in _execute(self, url, results)
    863 
    864     def _execute(self, url, results=True):
--> 865         response = self._request(url, statements=self.statements)
    866         content = response.json()
    867         self._manage_errors(content["errors"])

.../code/neo4j-rest-client/neo4jrestclient/query.pyc in _request(self, url, statements)
    860             return response
    861         else:
--> 862             raise TransactionException(response.status_code)
    863 
    864     def _execute(self, url, results=True):

TransactionException: Code [404]: Not Found. Nothing matches the given URI.
Element not found

The client is completely block unless calling .flush()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions