3 releases (1 stable)

1.0.0 Oct 10, 2021
0.1.1 Aug 25, 2020
0.1.0 Aug 24, 2020

#340 in Database interfaces


12K SLoC

C 5K SLoC // 0.0% comments C++ 4K SLoC // 0.1% comments Rust 2.5K SLoC // 0.0% comments Shell 52 SLoC // 0.1% comments

rsmgclient - Rust Memgraph Client

rsmgclient is Memgraph database adapter for Rust programming language. rsmgclient crate is the current implementation of the adapter. It is implemented as a wrapper around mgclient, the official Memgraph C/C++ client library.



  • Rust 1.42.0 or above
  • Prerequisites of mgclient:
    • A C compiler supporting C11 standard
    • CMake 3.8 or newer
    • OpenSSL 1.0.2 or newer

Installing from crates.io

Once prerequisites are met, if you want to use rsmgclient as library for your own Rust project, you can install it by using cargo:

cargo install rsmgclient

Building from Source

To contribute into rsmgclient or just looking closely how it is made, you will need:

Once rsmgclient is cloned, you will need to build it and then you can run the test suite to verify it is working correctly:

cargo build
# Run Memgraph based on the quick start guide
cargo test


Online documentation can be found on docs.rs pages.

Code Sample

src/main.rs is an example showing some of the basic commands:

use rsmgclient::{ConnectParams, Connection, MgError, Value};

fn execute_query() -> Result<(), MgError> {
    // Connect to Memgraph.
    let connect_params = ConnectParams {
        host: Some(String::from("localhost")),
    let mut connection = Connection::connect(&connect_params)?;

    // Create simple graph.
        "CREATE (p1:Person {name: 'Alice'})-[l1:Likes]->(m:Software {name: 'Memgraph'}) \
         CREATE (p2:Person {name: 'John'})-[l2:Likes]->(m);",

    // Fetch the graph.
    let columns = connection.execute("MATCH (n)-[r]->(m) RETURN n, r, m;", None)?;
    println!("Columns: {}", columns.join(", "));
    for record in connection.fetchall()? {
        for value in record.values {
            match value {
                Value::Node(node) => print!("{}", node),
                Value::Relationship(edge) => print!("-{}-", edge),
                value => print!("{}", value),


fn main() {
    if let Err(error) = execute_query() {
        panic!("{}", error)


~45K SLoC