GlueSQL is a SQL database library written in Rust which provides parser (sqlparser-rs), execution layer, and an optional storage (sled).
Developers can use GlueSQL to build their own SQL databases or they can simply use GlueSQL as an embedded SQL database using default storage.
You can simply use GlueSQL as an embedded SQL database, GlueSQL provides sled as a default storage engine.
In your Cargo.toml
toml
[dependencies]
gluesql = { version = "0.1.13", features = ["sled-storage"] }
```rust use gluesql::*;
fn main() { let storage = SledStorage::new("data.db").unwrap(); let mut glue = Glue::new(storage);
let sql = "
CREATE TABLE Glue (id INTEGER);
INSERT INTO Glue VALUES (100);
INSERT INTO Glue VALUES (200);
SELECT * FROM Glue WHERE id > 100;
DROP TABLE Glue;
";
for query in parse(sqls).unwrap() {
glue.execute(&query).unwrap();
}
} ```
Now you don't need to include sled-storage
. So in Cargo.toml
,
toml
[dependencies]
gluesql = "0.1.13"
All you only need to do is implementing 2 traits: Store
and StoreMut
!
In src/store.rs
,
```rust
pub trait Store
pub trait StoreMut Use SQL in web browsers! GlueSQL currently supports limited queries, it's in very early stage. You can see current query supports in src/tests/*. It's very early stage, please feel free to do whatever you want to. Examples - GlueSQL-js
GlueSQL-js provides 3 storage options,
* in-memory
* localStorage
* sessionStorage.SQL Features
CREATE
with 4 types: INTEGER
, FLOAT
, BOOLEAN
, TEXT
with an optional NULL
attribute.INSERT
, UPDATE
, DELETE
, SELECT
, DROP TABLE
Other expected use cases
gluesql-js
.Contribution
Only the thing you need to be aware of is...
- Except for src/glue.rs
and src/tests/
, there is no place to use mut
keyword.