neo4j-driver-python-skill

Implement Neo4j Python Driver v6.x query execution and transaction patterns.

101|35|Updated Jan 20, 2026
One-click install
npx skills add https://github.com/neo4j-contrib/neo4j-skills --skill neo4j-driver-python-skill
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: neo4j-driver-python-skill
Source: https://github.com/neo4j-contrib/neo4j-skills/tree/main/neo4j-driver-python-skill
Command: npx skills add https://github.com/neo4j-contrib/neo4j-skills --skill neo4j-driver-python-skill

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It helps you build reliable Python application code that connects to Neo4j and correctly manages driver sessions, transactions, async execution, and result handling.

Core Features & Use Cases

  • Driver lifecycle & connection setup: Create and reuse a single GraphDatabase.driver (or AsyncGraphDatabase) instance, including verify_connectivity, correct URI schemes, and supported authentication methods.
  • Correct query execution patterns: Use execute_query as the safe default, choose between managed transactions (execute_read / execute_write) and implicit transactions (session.run), and understand retry and streaming/eagerness behavior.
  • Robust results, types, and error handling: Access records safely, handle Result lifetimes and JSON serialization pitfalls, map Python/Cypher data types (including temporal and graph objects), and catch Neo4j exceptions like ConstraintError and TransientError.
  • Practical performance guardrails: Avoid common mistakes that cause session leaks, connection pool exhaustion, unnecessary round-trips (by always specifying database_/database=), and unsafe UNWIND batching inputs.

Quick Start

Use the neo4j-driver-python-skill to write a Python service that initializes the Neo4j driver once, runs read/write work using execute_query and managed transactions, and returns JSON-safe scalars from query results.

Frequently Asked Questions about neo4j-driver-python-skill

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I execute queries with the Neo4j Python driver in production?

To execute queries with the Neo4j Python driver safely, use `execute_query` as the default method for running queries without explicit transaction management, ensuring proper connection handling and result processing.

What is the difference between managed transactions and execute_query in the Neo4j Python driver?

Managed transactions using `execute_read` or `execute_write` offer automatic retries for transient errors, while `execute_query` provides a simpler, safe default for running queries without manual transaction control.

How do I handle asynchronous database operations with the Neo4j Python driver?

Handle asynchronous operations by using `AsyncGraphDatabase` to create a driver instance, enabling asyncio patterns for non-blocking query execution, managed transactions, and result streaming.

Why am I getting session leaks or connection pool exhaustion with the Neo4j Python driver?

Session leaks and connection pool exhaustion occur when driver instances are not reused properly; initialize a single `GraphDatabase.driver` instance and manage `Result` lifetimes correctly to prevent resource depletion.

How do I map Python data types to Cypher when using the Neo4j Python driver?

Map Python data types to Cypher by understanding the driver's automatic type conversion for temporal and graph objects, and use UNWIND batching conventions to safely pass lists and dictionaries as query parameters.

What is the correct way to handle Neo4j exceptions in a Python application?

Handle Neo4j exceptions by catching specific error classes like `ConstraintError` and `TransientError` to manage constraint violations and retryable transient failures, ensuring causal consistency during database operations.