Crates.io | skytable |
lib.rs | skytable |
version | 0.8.11 |
source | src |
created_at | 2021-05-06 04:58:22.889398 |
updated_at | 2024-09-12 12:56:45.772488 |
description | Official Rust client driver for Skytable |
homepage | |
repository | https://github.com/skytable/client-rust |
max_upload_size | |
id | 393695 |
size | 157,116 |
This library is the official client for the free and open-source NoSQL database Skytable. First, go ahead and install Skytable by following the instructions here. This library supports all Skytable versions that work with the Skyhash 2 Protocol. This version of the library was tested with the latest Skytable release (release 0.8.4). Read more about supported versions here.
📁 You can find some usage examples in this folder here.
This library only ships with the bare minimum that is required for interacting with Skytable. Once you have Skytable installed and running, you're ready to follow this guide!
We'll start by creating a new binary application and then running actions. Create a new binary application by running:
cargo new skyapp
Tip: You can see a full list of the available actions here.
First add this to your Cargo.toml
file:
skytable = "0.8"
You're ready to go!
use skytable::{
Query, Response, Config, query,
response::Rows,
};
#[derive(Query, Response)]
#[derive(Clone, PartialEq, Debug)] // we just do these for the assert (they are not needed)
struct User {
userid: String,
pass: String,
followers: u64,
email: Option<String>
}
let our_user = User { userid: "user".into(), pass: "pass".into(), followers: 120, email: None };
let mut db = Config::new_default("username", "password").connect().unwrap();
// insert data
let q = query!("insert into myspace.mymodel(?, ?, ?, ?)", our_user.clone());
db.query_parse::<()>(&q).unwrap();
// select data
let user: User = db.query_parse(&query!("select * from myspace.mymodel where username = ?", &our_user.userid)).unwrap();
assert_eq!(user, our_user);
// select multiple rows
let users: Rows<User> = db.query_parse(&query!("select all * from myspace.mymodel limit ?", 1000u64)).unwrap();
assert_eq!(users[0].userid, "user");
Contributions are always welcome. To submit patches please fork this repository and submit a pull request. If you find any bugs, please open an issue here.
This library is distributed under the Apache-2.0 License.