How to use the neo4j.exceptions.CypherSyntaxError function in neo4j

To help you get started, we’ve selected a few neo4j examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github technige / py2neo / test / test_cypher.py View on Github external
def test_error(self):
        with self.assertRaises(CypherSyntaxError):
            tx = Transaction(self.http_graph)
            tx.run("X")
            tx.commit()
github technige / py2neo / test / integration / test_database.py View on Github external
def test_can_generate_transaction_error(self):
        tx = self.graph.begin()
        with self.assertRaises(CypherSyntaxError):
            tx.run("X")
            tx.commit()
github technige / py2neo / test / test_transaction.py View on Github external
def test_can_generate_transaction_error(self):
        tx = self.graph.begin()
        with self.assertRaises(CypherSyntaxError):
            tx.run("X")
            tx.commit()
github sim51 / neo4j-fdw / neo4jPg / neo4jfdw.py View on Github external
def compute_table_stat(self):
        stats = 100000000
        if self.driver.supports_multi_db():
            session = self.driver.session(database=self.database)
        else:
            session = self.driver.session()
        try:
            rs = session.run('EXPLAIN ' + self.cypher, {})
            explain_summary = rs.consume().plan['args']
            stats = explain_summary['EstimatedRows']
            log_to_postgres('Stat for table is ' + str(explain_summary['EstimatedRows']), DEBUG)
        except CypherSyntaxError:
            raise RuntimeError("Bad cypher query : " + cypher)
        except CypherTypeError:
            raise RuntimeError("Bad cypher type in query : " + cypher)
        finally:
            session.close()

        log_to_postgres('Table stat is :' + str(stats), DEBUG)
        return stats
github technige / py2neo / py2neo / status.py View on Github external
class TransientError(GraphError):
    """ The database cannot service the request right now, retrying later might yield a successful outcome.
    """


client_errors = {

    # ConstraintError
    "Neo.ClientError.Schema.ConstraintValidationFailed": ConstraintError,
    "Neo.ClientError.Schema.ConstraintViolation": ConstraintError,
    "Neo.ClientError.Statement.ConstraintVerificationFailed": ConstraintError,
    "Neo.ClientError.Statement.ConstraintViolation": ConstraintError,

    # CypherSyntaxError
    "Neo.ClientError.Statement.InvalidSyntax": CypherSyntaxError,
    "Neo.ClientError.Statement.SyntaxError": CypherSyntaxError,

    # CypherTypeError
    "Neo.ClientError.Procedure.TypeError": CypherTypeError,
    "Neo.ClientError.Statement.InvalidType": CypherTypeError,
    "Neo.ClientError.Statement.TypeError": CypherTypeError,

    # Forbidden
    "Neo.ClientError.General.ForbiddenOnReadOnlyDatabase": Forbidden,
    "Neo.ClientError.General.ReadOnly": Forbidden,
    "Neo.ClientError.Schema.ForbiddenOnConstraintIndex": Forbidden,
    "Neo.ClientError.Schema.IndexBelongsToConstrain": Forbidden,
    "Neo.ClientError.Security.Forbidden": Forbidden,
    "Neo.ClientError.Transaction.ForbiddenDueToTransactionType": Forbidden,

    # Unauthorized
github sim51 / neo4j-fdw / neo4jPg / neo4jPGFunction.py View on Github external
jsonResult += node2json(object)

                # In 1.6 series of neo4j python driver a change to way relationship types are
                # constructed which means ABCMeta is __class__ and the mro needs to be checked
                elif any(c.__name__ == 'Relationship' for c in object.__class__.__mro__):
                    jsonResult += relation2json(object)
                elif object.__class__.__name__ == "Relationship":
                    jsonResult += relation2json(object)

                elif object.__class__.__name__ == "Path":
                    jsonResult += path2json(object)
                else:
                    jsonResult += json.dumps(object)
            jsonResult += "}"
            yield jsonResult
    except CypherSyntaxError as ce:
        raise RuntimeError("Bad cypher query: %s - Error message: %s" % (query,str(ce)))
    except CypherTypeError as ce:
        raise RuntimeError("Bad cypher type in query: %s - Error message: %s" % (query,str(ce)))
    finally:
        session.close()