Expand description
OtterSQL
๐ฆฆ An Embeddable SQL Executor in Rust
See README for more details.
This crate documentation describes the public API of OtterSQL. See above if you only want to use the CLI.
Installation
Add the following to your Cargo.toml
otter-sql = "0.1"
Getting started
use otter_sql::VirtualMachine;
fn main() {
// initialize an OtterSQL VM
let mut vm = VirtualMachine::default();
// execute SQL!
vm.execute(
"
CREATE TABLE table1
(
col1 INTEGER PRIMARY KEY NOT NULL,
col2 STRING NOT NULL
)
",
).unwrap();
// insert some values
vm.execute(
"
INSERT INTO table1 VALUES
(2, 'bar'),
(3, 'aaa')
",
).unwrap();
// two unwraps because this returns a `Result<Option<Table>, ...>`.
let res = vm.execute("SELECT * FROM table1").unwrap().unwrap();
println!("{}", res);
}
Output:
โญโโโโโโโฌโโโโโโโฎ
โ col1 โ col2 โ
โโโโโโโโผโโโโโโโค
โ 2 โ bar โ
โ 3 โ aaa โ
โฐโโโโโโโดโโโโโโโฏ
Re-exports
pub use column::Column;
pub use database::Database;
pub use ic::Instruction;
pub use ic::IntermediateCode;
pub use identifier::BoundedString;
pub use table::Table;
pub use value::Value;
pub use vm::VirtualMachine;
Modules
Intermediate code generation from the AST.
Columns in a table.
Databases.
SQL expressions and their evaluation.
Intermediate representation (IR) and instruction set for an SQL database.
Names used for tables, columns, schemas, DBs, etc.
Schemas (as in a namespace for tables, not a database schema).
Tables and rows.
Values contained in a table cell, its operations and errors.
The executor virtual machine, its registers and errors.