neo4j-driver-python-skill

Implements Python applications connecting to Neo4j using the official driver v6 API.

3|1|Updated Nov 30, 2025
One-click install
npx skills add https://github.com/PALabs-v1/AI_friend --skill neo4j-driver-python-skill-palabs-v1
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: neo4j-driver-python-skill
Source: https://github.com/PALabs-v1/AI_friend/tree/main/.claude/skills/neo4j-driver-python-skill
Command: npx skills add https://github.com/PALabs-v1/AI_friend --skill neo4j-driver-python-skill-palabs-v1

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires neo4j, python-dotenv, neo4j-rust-ext, fastapi, and includes references (resource) components.

What problem does it solve? Writing correct Neo4j client code in Python involves many subtle pitfalls: driver lifecycle management, transaction retry semantics, result cursor lifetimes, async patterns, and JSON serialization gotchas. This Skill provides authoritative guidance for the Neo4j Python Driver v6 so generated code follows best practices and avoids common production bugs. ## Core Features & Use Cases - Driver & Transaction Patterns: Covers driver singleton lifecycle, execute_query, managed transactions (execute_read/execute_write), implicit transactions, and explicit transactions with rollback handling. - Async & Performance: Provides AsyncGraphDatabase patterns for FastAPI, connection pool tuning, UNWIND batch writes, lazy streaming, and causal consistency with bookmarks. - Use Case: You are building a FastAPI service backed by Neo4j Aura. Use this Skill to set up a singleton async driver in the lifespan handler, run parameterized queries with execute_query, batch inserts with UNWIND, and handle ConstraintError correctly. ## Quick Start Use the neo4j-driver-python-skill to write a Python script that connects to my Neo4j Aura instance and runs a parameterized query.

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 connect to Neo4j from Python?

Install the neo4j package (not neo4j-driver, deprecated since v6) and create one driver with GraphDatabase.driver(URI, auth=(user, password)). Call verify_connectivity() at startup, keep the driver as a singleton, and always specify the database parameter on queries.

What is the difference between execute_query and session.run in the Neo4j Python driver?

execute_query is the recommended default: it auto-retries transient failures and returns results eagerly. session.run creates an implicit transaction suited for LOAD CSV or CALL IN TRANSACTIONS, with only a single retry on DBMS-marked idempotent errors since v6.2.

Does the Neo4j Python driver support asyncio and FastAPI?

Yes, AsyncGraphDatabase mirrors the sync API for asyncio applications. Create one async driver in the FastAPI lifespan handler, await every call, and never use the sync GraphDatabase inside async code since it blocks the event loop.

Why does json.dumps fail on Neo4j query results?

record.data() returns driver objects like Node, Relationship, and neo4j.time types that are not JSON-serializable. Project scalar fields in Cypher instead of returning whole nodes, or convert values explicitly with dict(node) or to_native().

Why does returning a Result from an execute_read callback fail?

Result is a lazy cursor backed by the open transaction, so it becomes invalid once the transaction closes and raises ResultConsumedError. Always consume results into a list inside the callback before returning.

When should I not use the Neo4j Python driver skill?

Use neo4j-cypher-skill for writing or optimizing Cypher queries, neo4j-migration-skill for driver version upgrades and breaking changes, and neo4j-graphrag-skill for GraphRAG pipelines built on the neo4j-graphrag package.