Crates.io | rusql |
lib.rs | rusql |
version | 0.0.1 |
source | src |
created_at | 2014-12-23 18:50:20.386289 |
updated_at | 2015-12-11 23:55:55.315022 |
description | A wannabe DBMS, in Rust |
homepage | https://github.com/mttr/rusql |
repository | https://github.com/mttr/rusql.git |
max_upload_size | |
id | 631 |
size | 140,160 |
A naive, SQL based RDBMS written in Rust.
My current intentions for this project are to expand upon my pathetically lacking knowledge of SQL, while having a bit of fun with Rust.
Based (very loosely) on SQLite, using SQLite's understanding of SQL as a sort of spec.
Uses rust-peg to generate the parser.
Ripped straight out of examples/example.rs
:
extern crate rusql;
use rusql::{rusql_exec, Rusql};
fn main() {
let mut db = Rusql::new();
let sql_str = "CREATE TABLE Foo(Id INTEGER PRIMARY KEY, Name TEXT); \
INSERT INTO Foo VALUES(1, \"Bar1\"); \
INSERT INTO Foo VALUES(2, \"Bar2\"); \
CREATE TABLE Yarp(Id INTEGER PRIMARY KEY, Name TEXT); \
INSERT INTO Yarp VALUES(1, \"Yarp1\"); \
INSERT INTO Yarp VALUES(2, \"Yarp2\"); \
SELECT * FROM Foo, Yarp;";
rusql_exec(&mut db, sql_str.to_string(), |entry, header| {
for (column, def) in entry.iter().zip(header.iter()) {
println!("{}: {}", def.name, column);
}
});
}
$ ./target/examples/example
Id: Integer(1)
Name: Text(Bar1)
Id: Integer(2)
Name: Text(Bar2)
Id: Integer(1)
Name: Text(Yarp1)
Id: Integer(2)
Name: Text(Yarp2)