Skip to main content
The FalkorDriver class provides connectivity to FalkorDB, a Redis-based graph database with RedisSearch integration.

Overview

FalkorDB is a multi-tenant graph database built on Redis. The FalkorDriver provides:
  • Redis-based graph storage
  • RedisSearch fulltext indexing
  • Multi-tenant database support
  • Connection to FalkorDB Cloud or on-premises
  • Automatic datetime conversion

Constructor

Parameters

str
default:"localhost"
The hostname where FalkorDB is running.For on-premises deployments, this is typically "localhost". For FalkorDB Cloud, use the provided cloud endpoint.Example: "localhost" or "cloud.falkordb.com"
int
default:"6379"
The port on which FalkorDB is listening.The default Redis port is 6379. FalkorDB Cloud may use different ports.Example: 6379
str | None
default:"None"
The username for authentication.Optional for on-premises deployments. Required for FalkorDB Cloud.Example: "admin"
str | None
default:"None"
The password for authentication.Optional for on-premises deployments. Required for FalkorDB Cloud.Example: "your-password"
FalkorDB | None
default:"None"
An existing FalkorDB client instance to reuse.If provided, the driver will use this client instead of creating a new one. Useful for sharing connections or custom client configurations.Example: FalkorDB(host="localhost", port=6379)
str
default:"default_db"
The name of the database (graph) to connect to.FalkorDB supports multiple graphs. Each graph is isolated.Example: "graphiti" or "user_graph"

Methods

execute_query

Execute a Cypher query and return results.
Parameters:
  • cypher_query_ (str) - The Cypher query to execute
  • **kwargs - Query parameters (automatically converted for FalkorDB)
Returns: tuple[list[dict], list[str], None] - Records, headers, and summary
FalkorDB does not support native datetime objects. The driver automatically converts datetime values to ISO format strings.

session

Create a new database session.
Parameters:
  • database (str | None) - Optional database name override
Returns: FalkorDriverSession - Session object

close

Close the driver and release connections.
Returns: None

build_indices_and_constraints

Create all required indices for Graphiti.
Parameters:
  • delete_existing (bool) - If True, delete existing indices before creating new ones
Returns: None
This method is automatically called during driver initialization.

health_check

Verify connectivity to FalkorDB.
Returns: None - Raises exception if connection fails

clone

Create a copy of the driver targeting a different database.
Parameters:
  • database (str) - The name of the database to target
Returns: GraphDriver - New driver instance

build_fulltext_query

Build a RedisSearch-compatible fulltext query string.
Parameters:
  • query (str) - The search query text
  • group_ids (list[str] | None) - Optional list of group IDs to filter by
  • max_query_length (int) - Maximum query length (default: 128)
Returns: str - RedisSearch formatted query
FalkorDB uses RedisSearch syntax with the @ prefix for field queries. The driver automatically formats queries and escapes reserved characters.

sanitize

Sanitize query text by replacing FalkorDB special characters with whitespace.
Parameters:
  • query (str) - The text to sanitize
Returns: str - Sanitized text with special characters replaced

Properties

provider

Returns the GraphProvider.FALKORDB enum value.

fulltext_syntax

The prefix used for fulltext field queries in RedisSearch syntax.

default_group_id

The default group ID used for FalkorDB queries.

Operations Properties

The driver exposes specialized operation interfaces:

Usage Examples

Basic Connection (On-Premises)

FalkorDB Cloud Connection

With Graphiti

Multi-Tenant Usage

Fulltext Search with RedisSearch

Reusing an Existing FalkorDB Client

Environment Variables

Common environment variables for FalkorDB configuration:
Load in your application:

Installation

FalkorDB support requires the optional falkordb extra:
Or install the FalkorDB client directly:

Datetime Handling

FalkorDB does not support native datetime objects. The driver automatically converts:
The conversion happens automatically in:
  • Query parameters
  • List values
  • Nested dictionary values

Stopwords

FalkorDB’s RedisSearch automatically filters common stopwords. The driver includes a comprehensive stopword list that mirrors RedisSearch behavior:
Stopwords are automatically removed when building fulltext queries.

Drivers Overview

Learn about the driver architecture

Graphiti

Main Graphiti class documentation

Neo4j Driver

Alternative production-ready driver

Kuzu Driver

Embedded analytics driver