Crates.io | reefdb |
lib.rs | reefdb |
version | 0.1.0 |
source | src |
created_at | 2023-05-06 15:56:42.612242 |
updated_at | 2023-05-06 15:56:42.612242 |
description | ReefDB is a minimalistic, in-memory and on-disk database management system written in Rust, implementing basic SQL query capabilities and full-text search. |
homepage | |
repository | https://github.com/sachaarbonel/reefdb |
max_upload_size | |
id | 858553 |
size | 97,545 |
ReefDB is a minimalistic, in-memory and on-disk database management system written in Rust, implementing basic SQL query capabilities and full-text search.
To use ReefDB, you can choose between an in-memory storage (InMemoryReefDB
) or on-disk storage (OnDiskReefDB
).
use reefdb::InMemoryReefDB;
fn main() {
let mut db = InMemoryReefDB::new();
let queries = vec![
"CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)",
"INSERT INTO users VALUES (1, 'Alice')",
"INSERT INTO users VALUES (2, 'Bob')",
"SELECT * FROM users WHERE id = 1",
];
for query in queries {
let result = db.query(query);
println!("Result: {:?}", result);
}
}
use reefdb::OnDiskReefDB;
fn main() {
let kv_path = "kv.db";
let index = "index.bin";
let mut db = OnDiskReefDB::new(kv_path.to_string(), index.to_string());
let queries = vec![
"CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)",
"INSERT INTO users VALUES (1, 'Alice')",
"INSERT INTO users VALUES (2, 'Bob')",
"SELECT * FROM users WHERE id = 1",
];
for query in queries {
let result = db.query(query);
println!("Result: {:?}", result);
}
}
use reefdb::InMemoryReefDB;
fn main() {
let mut db = InMemoryReefDB::new();
let queries = vec![
"CREATE TABLE books (title TEXT, author TEXT, description FTS_TEXT)",
"INSERT INTO books VALUES ('Book 1', 'Author 1', 'A book about the history of computer science.')",
"INSERT INTO books VALUES ('Book 2', 'Author 2', 'A book about modern programming languages.')",
"INSERT INTO books VALUES ('Book 3', 'Author 3', 'A book about the future of artificial intelligence.')",
"SELECT title, author FROM books WHERE description MATCH 'computer science'",
];
for query in queries {
let result = db.query(query);
println!("Result: {:?}", result);
}
}
use reefdb::InMemoryReefDB;
fn main() {
let mut db = InMemoryReefDB::new();
let queries = vec![
"CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)",
"INSERT INTO users VALUES (1, 'Alice')",
"INSERT INTO users VALUES (2, 'Bob')",
"DELETE FROM users WHERE id = 1",
"SELECT * FROM users",
];
for query in queries {
let result = db.query(query);
println!("Result: {:?}", result);
}
}
use reefdb::InMemoryReefDB;
fn main() {
let mut db = InMemoryReefDB::new();
let queries = vec![
"CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)",
"INSERT INTO users VALUES (1, 'Alice')",
"INSERT INTO users VALUES (2, 'Bob')",
"UPDATE users SET name = 'Charlie' WHERE id = 1",
"SELECT * FROM users",
];
for query in queries {
let result = db.query(query);
println!("Result: {:?}", result);
}
}
use reefdb::InMemoryReefDB;
fn main() {
let mut db = InMemoryReefDB::new();
let queries = vec![
"CREATE TABLE authors (id INTEGER PRIMARY KEY, name TEXT)",
"CREATE TABLE books (id INTEGER PRIMARY KEY, title TEXT, author_id INTEGER)",
"INSERT INTO authors VALUES (1, 'Alice')",
"INSERT INTO authors VALUES (2, 'Bob')",
"INSERT INTO books VALUES (1, 'Book 1', 1)",
"INSERT INTO books VALUES (2, 'Book 2', 2)",
"SELECT authors.name, books.title FROM authors INNER JOIN books ON authors.id = books.author_id",
];
for query in queries {
let result = db.query(query);
println!("Result: {:?}", result);
}
}
This project is licensed under the MIT License. See LICENSE for more information.