#db #simplistic #load #memory #expect #single-table

yanked query

query is a simplistic single-table database library

Uses old Rust 2015

0.1.2 Nov 5, 2017
0.1.1 Nov 5, 2017
0.1.0 Nov 5, 2017

#13 in #simplistic

GPL-3.0 license

15KB
162 lines

query https://docs.rs https://crates.io

General

query is a simplistic single-table database library

Example

// get some data to work with
let data = (0..10).collect();

// write the data to disk
let mut db = DB::create("test.db", data)
    .expect("can't create 'test.db'");

// change the data in memory
db.iter_mut()
	.for_each(|i| *i * 2);

// apply the changes
db.apply()
	.expect("can't update 'test.db'");

// delete the data in memory
drop(db);

// read the database from memory
let db = DB::load("test.db")
	.expect("can't read 'test.db'");

// all values have been multiplied by 10
assert_eq!(db.to_vec(), (0..100).step_by(10).collect());

lib.rs:

query is a simplistic single-table database

This crate provides functionality for very simple databases, you can only have one table in a database, you can't change the data in place and have to load the entire database into memory. But it's really simple.

Examples

#
// get some data to work with
let data = (0..10).collect();

// write the data to disk
let mut db = DB::create("test.db", data)
    .expect("can't create 'test.db'");

// change the data in memory
db.iter_mut()
    .for_each(|i| *i * 2);

// apply the changes
db.apply()
    .expect("can't update 'test.db'");

// delete the data in memory
drop(db);

// read the database from memory
let db = DB::load("test.db")
    .expect("can't read 'test.db'");

// all values have been multiplied by 10
assert_eq!(db.to_vec(), (0..100).step_by(10).collect());

Dependencies

~1–1.6MB
~30K SLoC