Giter Site home page Giter Site logo

ml4ai / rsmgclient Goto Github PK

View Code? Open in Web Editor NEW

This project forked from memgraph/rsmgclient

0.0 0.0 0.0 88 KB

Memgraph database adapter for Rust programming language.

Home Page: https://crates.io/crates/rsmgclient

License: Apache License 2.0

Shell 0.04% Rust 99.96%

rsmgclient's Introduction

rsmgclient - Rust Memgraph Client

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

Installation

Prerequisites

  • 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 a library for your own Rust project, you can install it using cargo:

cargo install rsmgclient

NOTE: The default OpenSSL path on Windows is C:\Program Files\OpenSSL-Win64\lib, if you would like to change that please provide OPENSSL_LIB_DIR env variable.

Building from Source

To contribute into rsmgclient or just to look more 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:

git submodule update --init
cargo build
# Please run Memgraph based on the quick start guide
cargo test

On MacOS, the build will try to detect OpenSSL by using MacPorts or Homebrew.

On Windows, bindgen requires libclang which is a part of LLVM. If LLVM is not already installed just go to the LLVM download page, download and install LLVM.exe file (select the option to put LLVM on the PATH). In addition, default OpenSSL path is C:\Program Files\OpenSSL-Win64\lib, if you would like to change that please provide OPENSSL_LIB_DIR env variable during the build phase.

Documentation

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")),
        ..Default::default()
    };
    let mut connection = Connection::connect(&connect_params)?;

    // Create simple graph.
    connection.execute_without_results(
        "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),
            }
        }
        println!();
    }
    connection.commit()?;

    Ok(())
}

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

rsmgclient's People

Contributors

marioherceg avatar gitbuda avatar mihaeljaic avatar adarshp avatar neuhausler avatar spacejam avatar dejankos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.