Rust

Connection options for Rust

ArcadeDB exposes multiple wire protocols, so you can pick the one your stack already speaks:

Neo4j BOLT — neo4rs

Cargo.toml:

[dependencies]
neo4rs = "0.7"
tokio = { version = "1", features = ["full"] }
use neo4rs::*;

#[tokio::main]
async fn main() -> Result<()> {
    let graph = Graph::new("bolt://localhost:7687", "root", "playwithdata").await?;
    let mut result = graph.execute(query("MATCH (n) RETURN n LIMIT 5")).await?;
    while let Ok(Some(row)) = result.next().await {
        println!("{:?}", row);
    }
    Ok(())
}

PostgreSQL Wire Protocol — postgres

Cargo.toml:

[dependencies]
postgres = "0.19"
use postgres::{Client, NoTls};

fn main() -> Result<(), postgres::Error> {
    let mut client = Client::connect(
        "host=localhost port=5432 dbname=mydatabase \
         user=root password=playwithdata",
        NoTls,
    )?;

    for row in client.query("SELECT FROM schema:types LIMIT 5", &[])? {
        let value: &str = row.get(0);
        println!("{}", value);
    }
    Ok(())
}

HTTP/JSON API — reqwest

Cargo.toml:

[dependencies]
reqwest = { version = "0.12", features = ["json", "blocking"] }
serde_json = "1"
use serde_json::json;

fn main() -> Result<(), reqwest::Error> {
    let body = json!({
        "language": "sql",
        "command":  "SELECT FROM schema:types LIMIT 5"
    });

    let res = reqwest::blocking::Client::new()
        .post("http://localhost:2480/api/v1/query/mydatabase")
        .basic_auth("root", Some("playwithdata"))
        .json(&body)
        .send()?
        .text()?;

    println!("{}", res);
    Ok(())
}