FalkorDB

Docker Hub Discord

Try Free

FalkorDB is a blazing fast graph database used for low latency & high throughput scenarios, under the hood it runs GraphBLAS to perform graph operations using sparse linear algebra.

Primary features

Give it a try

Launch an instance using docker, or use FalkorDB Clouds

docker run -p 6379:6379 -p 3000:3000 -it --rm falkordb/falkordb:latest

Once loaded you can interact with FalkorDB using any of the supported client libraries

Here we’ll use FalkorDB Python client to create a small graph representing a subset of motorcycle riders and teams taking part in the MotoGP league, once created we’ll start querying our data.


from falkordb import FalkorDB

# Connect to FalkorDB
db = FalkorDB(host='localhost', port=6379)

# Create the 'MotoGP' graph
g = db.select_graph('MotoGP')
# Clear out this graph in case you've run this script before.
g.delete()
g.query("""CREATE
           (:Rider {name:'Valentino Rossi'})-[:rides]->(:Team {name:'Yamaha'}),
           (:Rider {name:'Dani Pedrosa'})-[:rides]->(:Team {name:'Honda'}),
           (:Rider {name:'Andrea Dovizioso'})-[:rides]->(:Team {name:'Ducati'})""")

# Query which riders represents Yamaha?
res = g.query("""MATCH (r:Rider)-[:rides]->(t:Team)
                 WHERE t.name = 'Yamaha'
                 RETURN r.name""")

for row in res.result_set:
    print(row[0]) # Prints: "Valentino Rossi"

# Query how many riders represent team Ducati ?
res = g.query("""MATCH (r:Rider)-[:rides]->(t:Team {name:'Ducati'}) RETURN count(r)""")

print(res.result_set[0][0]) # Prints: 1

import { FalkorDB } from 'falkordb';

const db = await FalkorDB.connect({
    // username: 'myUsername',
    // password: 'myPassword',
    socket: {
        host: 'localhost',
        port: 6379
    }
})

console.log('Connected to FalkorDB')

const graph = db.selectGraph('MotoGP')

await graph.query(`CREATE (:Rider {name:'Valentino Rossi'})-[:rides]->(:Team {name:'Yamaha'}),
        (:Rider {name:'Dani Pedrosa'})-[:rides]->(:Team {name:'Honda'}),
        (:Rider {name:'Andrea Dovizioso'})-[:rides]->(:Team {name:'Ducati'})`)

result = await graph.query(`MATCH (r:Rider)-[:rides]->(t:Team) 
                            WHERE t.name = $name RETURN r.name`, 
                            {params: {name: 'Yamaha'}})
                            
console.log(result) // Valentino Rossi

console.log(await db.list())
console.log(await db.info())

db.close()

use falkordb::{FalkorClientBuilder, FalkorConnectionInfo};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Connect to FalkorDB
    let connection_info: FalkorConnectionInfo = "falkor://127.0.0.1:6379"
        .try_into()
        .expect("Invalid connection info");

    let client = FalkorClientBuilder::new_async()
        .with_connection_info(connection_info)
        .build()
        .await?;

    // Select the 'MotoGP' graph
    let mut graph = client.select_graph("MotoGP");

    // Clear out this graph in case you've run this script before.
    graph.delete().await?;

    graph
        .query(
            r#"CREATE
           (:Rider {name:'Valentino Rossi'})-[:rides]->(:Team {name:'Yamaha'}),
           (:Rider {name:'Dani Pedrosa'})-[:rides]->(:Team {name:'Honda'}),
           (:Rider {name:'Andrea Dovizioso'})-[:rides]->(:Team {name:'Ducati'})"#,
        )
        .execute()
        .await?;

    // Query which riders represent Yamaha?
    let mut nodes = graph
        .query(
            r#"MATCH (r:Rider)-[:rides]->(t:Team)
                 WHERE t.name = 'Yamaha'
                 RETURN r.name"#,
        )
        .execute()
        .await?;

    for node in nodes.data.by_ref() {
        println!("{:?}", node);
    }

    // Query how many riders represent team Ducati?
    let mut nodes = graph
        .query(r#"MATCH (r:Rider)-[:rides]->(t:Team {name:'Ducati'}) RETURN count(r)"#)
        .execute()
        .await?;

    for node in nodes.data.by_ref() {
        println!("{:?}", node);
    }

    Ok(())
}

package com.falkordb;

import com.falkordb.*;
import java.util.*;

public class FalkorDBExample {
    public static void main(String[] args) {
        // Connect to FalkorDB
        Driver driver = FalkorDB.driver("localhost", 6379);

        // Select the graph
        Graph graph = driver.graph("MotoGP");

        // Create graph data
        graph.query("CREATE (:Rider {name:'Valentino Rossi'})-[:rides]->(:Team {name:'Yamaha'}), " +
                    "(:Rider {name:'Dani Pedrosa'})-[:rides]->(:Team {name:'Honda'}), " +
                    "(:Rider {name:'Andrea Dovizioso'})-[:rides]->(:Team {name:'Ducati'})");

        // Query with parameters
        Map<String, Object> params = new HashMap<>();
        params.put("name", "Yamaha");

        ResultSet resultSet = graph.query(
            "MATCH (r:Rider)-[:rides]->(t:Team) " +
            "WHERE t.name = $name RETURN r.name", params);

        // Process query results
        for (Record record : resultSet) {
            String riderName = record.getValue("r.name").toString();
            System.out.println(riderName); // Valentino Rossi
        }

        // Close the connection
        driver.close();
    }
}

For additional demos please see visit Demos.

Client libraries

Language-specific clients have been written by the community and the FalkorDB team. The full list and links can be found on the Clients page.

Data import

When loading large graphs from CSV files, we recommend using falkordb-bulk-loader

Mailing List / Forum

Got questions? Please contact us at the FalkorDB forum.

License

FalkorDB is licensed under the the Server Side Public License v1 (SSPLv1).