{"id":6360,"library":"falkordb","title":"FalkorDB Python Client","description":"FalkorDB is a high-performance Knowledge Graph database tailored for Large Language Models (LLMs), leveraging sparse matrices and linear algebra for efficient querying with OpenCypher. The `falkordb` Python client provides an interface for interacting with a FalkorDB server instance. It is currently at version 1.6.0 and maintains an active release cadence with frequent updates.","status":"active","version":"1.6.0","language":"en","source_language":"en","source_url":"http://github.com/falkorDB/falkordb-py","tags":["database","graph database","redis","graph","cypher","LLM"],"install":[{"cmd":"pip install falkordb","lang":"bash","label":"Install falkordb"}],"dependencies":[{"reason":"Requires Python 3.10 or higher.","package":"python","optional":false},{"reason":"The falkordb client wraps redis-py for connection management. The client requires `redis>=7.1.0,<8.0.0` for its internal operations.","package":"redis","optional":false}],"imports":[{"symbol":"FalkorDB","correct":"from falkordb import FalkorDB"},{"note":"Use this for asynchronous operations.","symbol":"FalkorDB (async)","correct":"from falkordb.asyncio import FalkorDB"}],"quickstart":{"code":"import os\nfrom falkordb import FalkorDB\n\n# Ensure FalkorDB server is running, e.g., via Docker:\n# docker run -p 6379:6379 -p 3000:3000 -it --rm -v ./data:/var/lib/falkordb/data falkordb/falkordb\n\n# Connect to FalkorDB (default host/port)\ndb = FalkorDB(host=os.environ.get('FALKORDB_HOST', 'localhost'), port=int(os.environ.get('FALKORDB_PORT', 6379)))\n\n# Select a graph (or create if it doesn't exist)\ng = db.select_graph('social')\n\n# Create some data\ncreate_query = \"\"\"\nCREATE (alice:User {id: 1, name: 'Alice', email: 'alice@example.com'})\nCREATE (bob:User {id: 2, name: 'Bob', email: 'bob@example.com'})\nCREATE (alice)-[:FRIENDS_WITH {since: 2020}]->(bob)\n\"\"\"\ng.query(create_query)\n\n# Query the data\nquery = \"\"\"\nMATCH (u1:User)-[f:FRIENDS_WITH]->(u2:User)\nRETURN u1.name, u2.name, f.since\n\"\"\"\n\nresult = g.query(query)\n\n# Print results\nfor record in result.result_set:\n    print(f\"{record[0]} is friends with {record[1]} since {record[2]}\")\n\n# Close the connection (important for resource management)\ndb.close()","lang":"python","description":"This quickstart demonstrates how to connect to a running FalkorDB instance, select or create a graph, insert data using Cypher queries, and retrieve results. It's crucial to have a FalkorDB server running (e.g., via Docker) before executing this code."},"warnings":[{"fix":"Upgrade your Python environment to 3.10 or later.","message":"FalkorDB Python client v1.4.0 and later require Python 3.10 or higher. Older Python versions are no longer supported.","severity":"breaking","affected_versions":">=1.4.0"},{"fix":"Ensure your FalkorDB server is running on a Redis instance that is version 7.4 or higher, ideally Redis 8.x for the latest FalkorDB releases.","message":"The FalkorDB server itself requires Redis 7.4 or newer for optimal compatibility and latest features. While the Python client's `redis-py` dependency might be met with older Redis versions (e.g., Redis 7.1), using an outdated Redis server with FalkorDB can lead to unexpected behavior or missing functionality.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Call `db.close()` or `await db.aclose()` after completing your database operations.","message":"Explicitly close FalkorDB connections when they are no longer needed using `db.close()` or `await db.aclose()` for async clients. This prevents resource leaks and ensures proper cleanup, especially in long-running applications or when managing connection pools.","severity":"gotcha","affected_versions":"All versions (explicit methods added in v1.6.0)"},{"fix":"Be aware of this limitation when writing Cypher queries involving eager operations and `LIMIT`. Structure your queries to apply `LIMIT` after the eager operation has completed its full scope, if possible, or filter results at the client side if the server behavior is not desired.","message":"FalkorDB's `LIMIT` clause does not affect eager operations like `CREATE`, `SET`, `DELETE`, `MERGE`, and projections with aggregate functions. For example, `UNWIND [1,2,3] AS value CREATE (a {property: value}) RETURN a LIMIT 1` will create three nodes but only return one.","severity":"gotcha","affected_versions":"All versions"},{"fix":"To ensure operations consider all matching relationships, explicitly refer to the relationship's alias in the query (e.g., `MATCH (a)-[e]->(b) WHERE ID(e) >= 0 RETURN COUNT(b)` or `MATCH (a)-[e]->(b) RETURN COUNT(b), e.dummyval`).","message":"In Cypher queries, if a relationship in a `MATCH` pattern is not explicitly referenced elsewhere in the query, FalkorDB may only verify the existence of at least one matching relationship rather than operating on every single matching one. This can lead to incorrect counts or unexpected results in certain `COUNT()` scenarios.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z"}