Choose a target¶
server_version is required. It declares the Neo4j release the rendered text will run
on, and the declared release decides which syntax is accepted. The library never probes a
server. Neo4j 5.26 LTS is the minimum supported release. Earlier 5.x releases and 4.x are
unsupported.
Use a two- or three-component string, such as
"5.26"or"2026.10.2". A one-component or four-component spelling is refused, as is a leadingvor a hyphenated date."2026.11.22"is accepted, because the components are numeric and the library does not validate them as a calendar date.Releases are compared numerically, so 5.26 is newer than 5.9. Patch components are retained.
Missing, malformed or unsupported releases fail when
Configurationis built.Declaring a release does not verify the actual server or its database-default language.
Let each statement select its language¶
Language.AUTO is the default. It selects a prefix from the statement’s syntax
requirements, not from the newest language the declared server offers:
A statement with no language floor renders without a prefix.
A release-only requirement does not add a prefix.
A requirement with a Cypher 25 language floor selects
CYPHER 25for that statement.
The same renderer can therefore render an ordinary statement unprefixed and select a language for another statement. Selecting a language never bypasses a release floor.
from cypher_dsl import Configuration, Renderer, match, node
person = node("Person", name="p")
statement = match(person).returning(person)
renderer = Renderer.get(Configuration(server_version="2026.10"))
print(renderer.render(statement).cypher)
MATCH (p:Person) RETURN p
Pin the language in the text¶
Language.CYPHER_5 and Language.CYPHER_25 always render their prefix. A pinned
language that cannot express a statement’s required syntax is refused. Pinning makes the
language explicit at the cost of restricting which syntax the statement can use.
from cypher_dsl import Configuration, Language, Renderer, match, node
person = node("Person", name="p")
statement = match(person).returning(person)
for language in (Language.CYPHER_5, Language.CYPHER_25):
configuration = Configuration(
server_version="2026.10.2", language=language, pretty_print=True
)
print(Renderer.get(configuration).render(statement).cypher)
CYPHER 5
MATCH (p:Person) RETURN p
CYPHER 25
MATCH (p:Person) RETURN p
CYPHER 5 is available on every supported release. CYPHER 25 needs Neo4j 2025.06 or
later, the one language floor the library enforces at construction. The Select Cypher
version manual
states how a query selects a language.
An unavailable language is rejected when the configuration is built:
from cypher_dsl import Configuration, Language
from cypher_dsl.errors import UnsupportedFeatureError
try:
Configuration(server_version="5.26.0", language=Language.CYPHER_25)
except UnsupportedFeatureError as error:
print(error)
CYPHER 25 requires Neo4j 2025.06 or later, but server_version is 5.26.0.
Select a compatible release or language.
Suppress the prefix¶
Language.NONE never renders a language prefix. It still checks every release floor,
but leaves the language to the database default. A release that supports
Cypher 25 can still have Cypher 5 as its database default. Suppressing a required prefix
then produces text that the configured default cannot parse. The library does not check
that default, so the application must control it.
from cypher_dsl import Configuration, Language, Renderer, match, node
person = node("Person", name="p")
configuration = Configuration(
server_version="2026.10", language=Language.NONE
)
renderer = Renderer.get(configuration)
print(renderer.render(match(person).returning(person)).cypher)
MATCH (p:Person) RETURN p
Quote every name¶
Configuration(server_version="5.26", always_escape_names=True) backticks every
identifier. The default quotes only names that need it, which keeps output close to
hand-written Cypher. Forced escaping produces valid but noisy text. It does not quote the
segments of a function or procedure name, so fn("my.fun") still renders my.fun and
call_procedure("my.proc") still renders my.proc. How names are quoted covers the identifier and parameter rules.
Render statements for reading¶
Configuration(server_version="5.26", pretty_print=True) permits layout breaks in the
structured syntax of a statement. Caller-supplied raw text is written unchanged. The
layout keeps a group on one line while it fits the remaining 120 columns, so a short
statement stays on one line. A single token longer than the width is not broken. In pretty
output, a language prefix always sits on its own line, so RETURN 1 is one line and the
same statement with a CYPHER 25 pin is two. The default renders one line, which stays
cacheable and log-friendly.
from cypher_dsl import Configuration, Renderer, desc, match, node, param
person = node("Person", name="p")
statement = (
match(person)
.where(
(person["rating"] > param("min_rating"))
& (person["email"] == param("email"))
)
.returning(person["display_name"], person["rating"])
.order_by(desc(person["rating"]))
.skip(param("offset"))
.limit(param("limit"))
)
renderer = Renderer.get(Configuration(server_version="5.26", pretty_print=True))
print(renderer.render(statement).cypher)
MATCH (p:Person)
WHERE p.rating > $min_rating AND p.email = $email
RETURN p.display_name, p.rating
ORDER BY p.rating DESC SKIP $offset LIMIT $limit