dengine

Crates.iodengine
lib.rsdengine
version0.1.3
sourcesrc
created_at2018-09-22 17:36:03.531845
updated_at2018-09-29 09:39:55.89772
descriptionmysql/sqlite abstraction lib
homepage
repositoryhttps://github.com/hrishimk/dengine
max_upload_size
id86011
size46,484
hrishi (hrishimk)

documentation

README

dengine

A RUST API over MYSQL and SQLITE APIs.

Libraries used

Usage

// extern crate dengine;
// #[macro_use]
// extern crate dengine_derive;

use dengine::Connectionable;
use dengine::Queryable;
use dengine::Row;
type DbCon = dengine::sqlite::Connection;

#[derive(Debug, Queryable)]
struct User {
    id: u64,
    name: String,
}

let con = DbCon::new(":memory:").unwrap();

let sql = "CREATE TABLE user (id INTEGER NOT NULL, name TEXT NOT NULL)";

con.execute(sql, ()).unwrap();

let sql = "INSERT INTO user (id, name) VALUES (?, ?), (?, ?)";
con.execute(sql, (1, "name1", 2, "name2")).unwrap();

let sql = "SELECT * from user";
let res: Vec<User> = con.array(sql, (), false).unwrap();

println!("{:?}", res);

//[User { id: 1, name: "name1" }, User { id: 2, name: "name2" }]

Important: Use https://github.com/diesel-rs/diesel instead of this lib

This library is created only because I am too stupid too understand the diesel documentation.

Commit count: 35

cargo fmt