Neo4j Enterprise features

cvcdocdb targets Neo4j Community Edition, and that is the default mode of Neo4jGraph. The methods below are only enabled with Neo4jGraph(..., edition="enterprise").

Warning

They require a valid Neo4j Enterprise license and are not fully tested: CI runs on Neo4j Community only.

Optional Neo4j Enterprise Edition features for Neo4jGraph.

cvcdocdb targets Neo4j Community Edition: that’s what its test suite and CI run against, and Neo4jGraph defaults to edition="community". In that mode every method in this module raises EnterpriseFeatureError without contacting the server.

Passing edition="enterprise" to Neo4jGraph enables them:

Warning

Enterprise features require a valid Neo4j Enterprise license (or an evaluation/developer license accepted under its terms). They are not fully tested: the regular test suite only checks the generated Cypher and the Community-mode guards; the tests against a real Enterprise server run only when NEO4J_ENTERPRISE_URL is set, which CI doesn’t.

None of these constraints is created automatically. In particular a NODE KEY on a label that cvcdocdb uses with several pk shapes will reject the nodes of the other shapes — apply it only to labels with a single pk shape.

cvcdocdb.neo4j_enterprise.COMMUNITY_EDITION = 'community'

Valid values for Neo4jGraph(edition=...).

cvcdocdb.neo4j_enterprise.CONSTRAINT_PREFIX = 'cvcdocdb_'

Prefix of the default constraint names created by this module.

exception cvcdocdb.neo4j_enterprise.EnterpriseFeatureError[source]

Bases: RuntimeError

An operation needs Neo4j Enterprise Edition, but the graph is in Community mode or the server isn’t Enterprise.

cvcdocdb.neo4j_enterprise.node_key_constraint_statement(main_label, properties, name=None)[source]

(constraint name, CREATE CONSTRAINT statement) for a NODE KEY.

Parameters:
Return type:

tuple[str, str]

cvcdocdb.neo4j_enterprise.existence_constraint_statement(label, prop, entity='node', name=None)[source]

(constraint name, CREATE CONSTRAINT statement) for IS NOT NULL.

Parameters:
Return type:

tuple[str, str]

cvcdocdb.neo4j_enterprise.type_constraint_statement(label, prop, cypher_type, entity='node', name=None)[source]

(constraint name, CREATE CONSTRAINT statement) for IS :: <TYPE>.

Parameters:
Return type:

tuple[str, str]

cvcdocdb.neo4j_enterprise.normalize_edition(edition)[source]

Validate Neo4jGraph(edition=...); returns it lower-cased.

Parameters:

edition (Any)

Return type:

str

class cvcdocdb.neo4j_enterprise.Neo4jEnterpriseMixin[source]

Bases: object

Enterprise-only operations of Neo4jGraph.

Expects the host class to provide _driver, _session, _tx and edition. See the module docstring for the license/testing caveats.

edition: str
server_edition()[source]

Edition reported by the server ("community" or "enterprise"), from dbms.components(). Works in both modes.

Return type:

str

drop_constraint(name)[source]

Drop a constraint by name if it exists (works in both editions).

Parameters:

name (str)

Return type:

None

create_node_key_constraint(main_label, properties, name=None)[source]

Enterprise only. Require every main_label node to have properties set, and their combination to be unique. Idempotent.

Fails (server-side) if existing nodes violate it — including nodes of the label inserted with a different pk shape.

Returns:

The constraint name (cvcdocdb_nodekey_<Label>_<props> by default).

Raises:

EnterpriseFeatureError – In Community mode or on a Community server.

Parameters:
Return type:

str

create_property_existence_constraint(label, prop, entity='node', name=None)[source]

Enterprise only. Require prop on every node with label (entity="node") or every relationship of type label (entity="relationship"). Idempotent.

Returns:

The constraint name (cvcdocdb_exists_<label>_<prop> by default).

Raises:

EnterpriseFeatureError – In Community mode or on a Community server.

Parameters:
Return type:

str

create_property_type_constraint(label, prop, cypher_type, entity='node', name=None)[source]

Enterprise only, Neo4j 5.9+. Require prop (when present) to have Cypher type cypher_type — e.g. "STRING", "INTEGER", "LIST<STRING NOT NULL>". Idempotent.

Returns:

The constraint name (cvcdocdb_type_<label>_<prop> by default).

Raises:

EnterpriseFeatureError – In Community mode or on a Community server.

Parameters:
Return type:

str

create_database(name, wait=True)[source]

Enterprise only. Create a user database if it doesn’t exist. Runs on the system database; needs the CREATE DATABASE privilege. With wait=True returns once the database is online.

Raises:

EnterpriseFeatureError – In Community mode or on a Community server.

Parameters:
Return type:

None

drop_database(name, wait=True)[source]

Enterprise only. Drop a user database (and all its data) if it exists. Irreversible. Runs on the system database.

Raises:

EnterpriseFeatureError – In Community mode or on a Community server.

Parameters:
Return type:

None