1 unstable release

Uses old Rust 2015

0.0.1 Dec 23, 2014

#23 in #having

130KB
2.5K SLoC

rusql

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.

Example

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)

No runtime deps