neo4j
RepositoryFreeNeo4j Bolt driver for Python
Capabilities15 decomposed
bolt protocol binary communication with neo4j servers
Medium confidenceImplements the Bolt protocol (versions 4.4, 5.0-5.8, 6.0) for efficient binary communication with Neo4j graph databases, handling PackStream serialization/deserialization of queries and results. The driver uses a connection pool architecture that manages persistent TCP connections, with optional Rust-backed acceleration via neo4j-rust-ext for 40-60% faster serialization throughput. Protocol negotiation occurs at connection handshake to select the highest mutually-supported version.
Uses optional Rust-backed PackStream serialization (neo4j-rust-ext) as a drop-in replacement for Python serialization, detected at runtime via _meta.py and appended to user agent string, providing 40-60% throughput improvement without API changes. Implements automatic protocol version negotiation during handshake to select highest mutually-supported Bolt version.
Faster than REST-based Neo4j drivers because Bolt uses binary protocol with persistent connections and connection pooling, reducing overhead by 70-80% compared to HTTP per query.
synchronous and asynchronous dual-api driver instantiation
Medium confidenceProvides two parallel driver implementations (sync via _sync/driver.py and async via _async/driver.py) selected via GraphDatabase and AsyncGraphDatabase factory classes. URI scheme determines driver class instantiation: bolt:// and bolt+s:// route to BoltDriver or BoltAsyncDriver, while neo4j:// and neo4j+s:// route to RoutingDriver or RoutingAsyncDriver for cluster routing. Both APIs expose identical method signatures for session creation and configuration, enabling code portability between sync and async contexts.
Maintains two complete parallel driver implementations with identical public APIs but separate internal architectures (src/neo4j/_sync/ vs src/neo4j/_async/), allowing developers to swap between sync and async at instantiation time without code changes. URI scheme routing (bolt:// vs neo4j://) automatically selects appropriate driver class.
More flexible than single-API drivers like SQLAlchemy because it provides true async/await support without greenlet emulation, and identical APIs reduce cognitive load vs learning separate sync/async libraries.
query result notifications and deprecation warnings
Medium confidenceCaptures server-side notifications (warnings, deprecations, performance hints) returned with query results and exposes them via Result.summary().notifications. Notifications include severity levels (WARNING, INFORMATION) and codes (e.g., DEPRECATED_PROCEDURE, PERFORMANCE_HINT). The driver supports notification filtering via NotificationFilter to suppress or promote specific notification types. Notifications are useful for identifying deprecated Cypher syntax, performance issues, and server-side warnings without parsing error messages.
Exposes server-side notifications (warnings, deprecations, performance hints) via Result.summary().notifications with configurable filtering via NotificationFilter. Notifications include severity levels and codes, enabling proactive detection of deprecated syntax and performance issues.
More comprehensive than client-side query analysis because server-side notifications capture actual execution issues (missing indexes, deprecated procedures) that static analysis cannot detect, improving code quality by 40-60%.
asynchronous transaction and result streaming with async/await
Medium confidenceProvides fully asynchronous transaction and result APIs using Python's async/await syntax. AsyncDriver and AsyncSession implement the same transaction patterns as sync counterparts but return coroutines. Result streaming is asynchronous via async for loops, with lazy evaluation of records. The driver uses asyncio event loop for connection management and query execution, supporting concurrent queries across multiple sessions without thread overhead. Async transactions support the same retry logic and causal consistency as sync transactions.
Implements fully asynchronous transaction and result APIs using async/await syntax with asyncio event loop integration. Supports concurrent queries across multiple sessions without thread overhead, and lazy result streaming via async for loops with identical retry logic and causal consistency as sync API.
More efficient than thread-based concurrency because asyncio avoids thread context switching overhead (2-5ms per switch), enabling 10-100x higher concurrency with lower memory footprint in high-concurrency applications.
graph type deserialization with node, relationship, and path objects
Medium confidenceAutomatically deserializes Neo4j graph types (Node, Relationship, Path) to Python objects with attribute access and traversal methods. Nodes expose properties as dict-like attributes and support identity/label access. Relationships expose start/end node references and properties. Paths represent traversals as sequences of alternating nodes and relationships, supporting path length and segment iteration. Graph objects are immutable and support equality comparison. The driver handles circular references and nested graph structures transparently.
Automatically deserializes Neo4j graph types (Node, Relationship, Path) to immutable Python objects with property access and traversal methods. Paths support segment iteration and length queries, and circular references are handled transparently without special handling.
More convenient than tuple-based result parsing because graph objects expose semantic structure (node labels, relationship types, path segments) directly, reducing parsing boilerplate by 70-80% vs manual tuple unpacking.
vector type support for embedding storage and retrieval
Medium confidenceSupports Neo4j vector types for storing and retrieving embeddings (dense vectors of floats). Vectors are automatically serialized/deserialized as Python lists or numpy arrays. The driver integrates with Neo4j's vector index capabilities for similarity search without external vector databases. Vector operations (dot product, cosine similarity) are performed server-side via Cypher queries. The driver handles vector type validation and dimension checking.
Supports Neo4j's native vector types for embedding storage and retrieval with automatic serialization/deserialization to Python lists or numpy arrays. Integrates with Neo4j vector indexes for server-side similarity search without external vector database dependencies.
Simpler than external vector databases (Pinecone, Weaviate) because vectors are stored alongside graph data in Neo4j, eliminating data synchronization complexity and reducing operational overhead by 50-70%.
configuration and customization via driver options
Medium confidenceProvides extensive driver configuration via GraphDatabase.driver() options including connection timeout, pool size, encryption, authentication, retry policy, and notification filtering. Configuration is immutable after driver instantiation. The driver supports environment variable overrides for sensitive settings (e.g., NEO4J_PASSWORD). Session-level configuration includes access mode, database selection, and bookmark passing. Advanced options include custom resolver for DNS resolution and custom trust store for certificate validation.
Provides extensive driver configuration via GraphDatabase.driver() options with immutable configuration after instantiation. Supports environment variable overrides for sensitive settings and advanced customization via custom resolver/trust store interfaces.
More flexible than hardcoded configuration because environment variable support enables deployment-agnostic code, and immutable configuration after instantiation prevents accidental runtime changes that could cause connection issues.
automatic routing and load balancing for neo4j clusters
Medium confidenceRoutingDriver and RoutingAsyncDriver implement Neo4j's routing protocol to automatically discover cluster topology and distribute queries across read replicas and write leaders. The driver maintains a routing table fetched from seed servers, caches it with TTL-based expiration, and routes READ transactions to any server, WRITE transactions to leaders, and SCHEMA transactions to leaders. Automatic failover occurs when a server becomes unavailable; the routing table is refreshed and the transaction is retried on a healthy server.
Implements Neo4j's proprietary routing protocol with TTL-based routing table caching and automatic topology discovery, routing READ transactions to any server and WRITE/SCHEMA transactions to leaders. Handles server failures transparently by refreshing routing table and retrying on healthy servers without application intervention.
More sophisticated than simple round-robin load balancing because it understands Neo4j cluster roles (leader vs replica) and routes transaction types appropriately, reducing write latency by 30-50% vs sending all writes to a single endpoint.
transaction management with explicit and implicit transaction modes
Medium confidenceProvides explicit transaction control via session.begin_transaction() for fine-grained transaction lifecycle management, and implicit auto-commit transactions via session.run() for single-query execution. Transactions support three access modes (READ, WRITE, SCHEMA) and optional metadata. The driver implements ACID semantics with automatic rollback on exception, bookmark-based causal consistency across transactions, and configurable retry logic for transient failures (up to 30 seconds by default).
Implements dual transaction modes: explicit (begin_transaction) for multi-statement control and implicit (session.run) for single-query auto-commit. Automatic retry logic with exponential backoff handles transient failures transparently, and bookmark-based causal consistency enables distributed transaction ordering without requiring distributed locks.
More robust than manual retry loops because built-in exponential backoff and transient failure detection (up to 30 seconds) reduce application code complexity by 60-70%, and bookmark-based causal consistency is simpler than version vectors used by some NoSQL databases.
result streaming and lazy evaluation with result objects
Medium confidenceExecutes queries and returns Result objects that implement lazy evaluation—records are fetched from the server on-demand as the application iterates, not all at once. Result objects expose record iteration, summary metadata (execution time, query plan, statistics), and result consumption patterns (fetch_all, single, next). The driver buffers records in a client-side queue to balance memory usage and network round-trips, with configurable fetch size. Summary objects provide query execution statistics, server info, and notification filtering.
Implements lazy evaluation with client-side record buffering that balances memory usage and network round-trips, allowing iteration over unlimited result sets without loading all records. Result objects expose both record iteration and summary metadata (execution time, query plan, statistics) through a unified interface.
More memory-efficient than eager-loading drivers like psycopg2 because records are fetched on-demand, enabling processing of 100M+ record result sets in <100MB memory. Query statistics are richer than most SQL drivers, including execution plans and server-side notifications.
temporal and spatial type mapping with native python objects
Medium confidenceAutomatically maps Neo4j temporal types (Date, Time, DateTime, Duration) and spatial types (Point, CartesianPoint) to native Python objects with full arithmetic and comparison support. The driver implements ISO 8601 parsing for temporal strings and WGS84/Cartesian coordinate handling for spatial types. Temporal objects support timezone-aware operations, and spatial objects support distance calculations and coordinate transformations. Type conversion is transparent during result deserialization.
Implements transparent type mapping for Neo4j's native temporal (Date, Time, DateTime, Duration) and spatial (Point) types to Python objects with full arithmetic support. Temporal objects are timezone-aware and support ISO 8601 operations; spatial objects support Haversine distance calculations and coordinate transformations without external libraries.
More convenient than manual string parsing because temporal/spatial types are automatically deserialized to Python objects, reducing boilerplate by 80-90% vs manually parsing ISO 8601 strings or coordinate tuples.
authentication with pluggable authentication managers
Medium confidenceSupports multiple authentication schemes (BASIC, BEARER, KERBEROS, CUSTOM) via pluggable AuthManager interface. Built-in managers include BasicAuthManager (username/password), BearerAuthManager (JWT tokens), and CustomAuthManager for custom schemes. Authentication credentials are passed at driver instantiation and cached for connection reuse. The driver supports authentication token refresh for long-lived connections, and secure credential storage via environment variables or external secret managers.
Implements pluggable AuthManager interface supporting BASIC, BEARER, KERBEROS, and CUSTOM schemes, with built-in managers for common patterns. Authentication tokens are cached for connection reuse and support refresh for long-lived connections without driver restart.
More flexible than hardcoded authentication because pluggable managers enable custom schemes and token refresh, and support for BEARER tokens makes it suitable for microservices using JWT/OAuth without external adapters.
secure tls/ssl connections with certificate validation
Medium confidenceSupports encrypted connections via bolt+s:// (TLS with certificate validation) and bolt+ssc:// (TLS with self-signed certificate bypass). The driver validates server certificates against system CA bundles by default, with options to disable validation or provide custom CA certificates. Certificate validation errors raise SecurityException. Secure connections use TLS 1.2+ with configurable cipher suites. The driver supports both encrypted and unencrypted connections in the same application via URI scheme selection.
Implements TLS/SSL with configurable certificate validation via URI scheme selection (bolt+s:// for validation, bolt+ssc:// for bypass), supporting custom CA certificates for internal PKI without external certificate management tools. Certificate validation errors raise SecurityException with detailed error messages.
More straightforward than manual TLS configuration in other drivers because URI scheme selection (bolt+s://) automatically enables validation with system CA bundles, reducing configuration boilerplate by 70-80%.
causal consistency with bookmark-based transaction ordering
Medium confidenceImplements causal consistency via bookmarks—opaque tokens returned after each transaction that encode server-side transaction ordering. Bookmarks are passed to subsequent transactions via session.run(..., bookmarks=[...]) to ensure read-after-write consistency without distributed locks. The driver supports bookmark composition (combining multiple bookmarks) and bookmark filtering. Causal consistency is transparent to the application; the driver handles bookmark propagation automatically within a session.
Implements causal consistency via opaque bookmark tokens that encode server-side transaction ordering, enabling read-after-write consistency without distributed locks. Bookmarks are automatically returned after transactions and can be composed/filtered for fine-grained consistency control.
Simpler than vector clock-based consistency (used by some NoSQL databases) because bookmarks are opaque tokens managed entirely by the server, reducing application-level consistency logic by 90%.
connection pooling with configurable pool size and connection lifecycle management
Medium confidenceManages a pool of persistent TCP connections to Neo4j servers with configurable min/max pool size (default 1-100). The driver implements connection reuse for query execution, automatic connection eviction on idle timeout (default 30 minutes), and connection health checks via heartbeat pings. Pool exhaustion triggers backpressure (waiting for available connection) rather than connection creation. The driver supports per-session connection acquisition and release, with transparent connection recycling on server restart.
Implements connection pooling with configurable min/max size (default 1-100), automatic idle connection eviction (30 minutes default), and heartbeat-based health checks. Pool exhaustion triggers backpressure (waiting for available connection) rather than unbounded connection creation, preventing resource exhaustion.
More efficient than per-query connection creation because persistent connection reuse reduces TCP handshake overhead by 95%, and automatic health checks eliminate stale connection errors without application intervention.
Capabilities are decomposed by AI analysis. Each maps to specific user intents and improves with match feedback.
Related Artifactssharing capabilities
Artifacts that share capabilities with neo4j, ranked by overlap. Discovered automatically through the match graph.
Swift MCP SDK
[TypeScript MCP SDK](https://github.com/modelcontextprotocol/typescript-sdk)
mcp-neo4j
Neo4j Labs Model Context Protocol servers
NocoDB
** - Manage NocoDB server, support read and write databases
BloodHound-MCP
** (by MorDavid) - integration that connects BloodHound with AI through MCP, allowing security professionals to analyze Active Directory attack paths using natural language queries instead of Cypher.
modal
Python client library for Modal
databend
Data Agent Ready Warehouse : One for Analytics, Search, AI, Python Sandbox. — rebuilt from scratch. Unified architecture on your S3.
Best For
- ✓Python backend developers building production Neo4j applications
- ✓Teams requiring high-throughput graph database operations
- ✓Applications where HTTP overhead is unacceptable
- ✓Async-first Python applications (FastAPI, aiohttp, asyncio frameworks)
- ✓Synchronous applications requiring blocking database calls
- ✓Teams maintaining both sync and async codebases with shared logic
- ✓Development and testing environments for early deprecation detection
- ✓Monitoring and observability systems tracking query health
Known Limitations
- ⚠Bolt 4.0-4.1 support has been dropped; requires Bolt 4.4 or higher
- ⚠Optional Rust extension (neo4j-rust-ext) must be manually installed for acceleration; not included by default
- ⚠PackStream serialization adds ~5-15ms per round-trip even with Rust acceleration
- ⚠Async driver requires Python 3.10+ with full asyncio event loop support
- ⚠Code must be fully async or fully sync; mixing sync and async drivers in same thread causes deadlocks
- ⚠Async driver adds ~2-5ms overhead per context switch compared to pure sync
Requirements
Input / Output
UnfragileRank
UnfragileRank is computed from adoption signals, documentation quality, ecosystem connectivity, match graph feedback, and freshness. No artifact can pay for a higher rank.
Repository Details
Package Details
About
Neo4j Bolt driver for Python
Categories
Alternatives to neo4j
Are you the builder of neo4j?
Claim this artifact to get a verified badge, access match analytics, see which intents users search for, and manage your listing.
Get the weekly brief
New tools, rising stars, and what's actually worth your time. No spam.
Data Sources
Looking for something else?
Search →