rsmgclient
is a 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 client library.
rsmgclient
is a wrapper around the mgclient Memgraph
client library. To install it from sources you will need:
- Rust - 1.42.0 or above
- A C compiler supporting C11 standard
- mgclient has to be installed because
rsmgclient
statically linksmgclient
- Memgraph
Once prerequisites are met, if you want to use it as library for your own Rust project, you can
install rsmgclient using cargo
to download it from crates.io:
$ cargo install rsmgclient
To use rsmgclient
for contributing or just looking closely how it is made, you will need:
- Cloned rsmgclient repository
- Rust - 1.42.0-nightly or above
- A C compiler supporting C11 standard
- mgclient
- Memgraph
Once rsmgclient is installed, you will need to build it and then you can run the test suite to verify it is working correctly.
$ cargo build
$ cargo test
Online documentation can be found on docs.rs pages.
Here is an example showing some of the basic commands:
use rsmgclient::{ConnectParams, Connection};
let connect_params = ConnectParams {
host: Some(String::from("localhost")),
..Default::default()
};
let mut connection = Connection::connect(&connect_params)?;
let query = "CREATE (u:User {name: 'Alice'})-[l:Likes]->(m:Software {name: 'Memgraph'}) RETURN u, l, m";
let columns = connection.execute(query, None)?;
println!("Columns: {}", columns.join(", "));
let records = connection.fetchall()?;
for value in &records[0].values {
println!("{}", value);
}
connection.commit()?;