GlueSQL
SQL Database Engine as a Library
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.
Standalone Mode
You can simply use GlueSQL as an embedded SQL database, GlueSQL provides sled as a default storage engine.
Installation
In your Cargo.toml
[]
= "0.3"
Usage
use ;
SQL Library Mode (For Custom Storage)
Installation
Now you don't need to include sled-storage
. So in Cargo.toml
,
[]
= { = "0.3", = false, = ["alter-table"] }
# alter-table is optional.
# If your DB does not have plan to support ALTER TABLE, then use this below.
= { = "0.3", = false }
Usage
All you only need to do is implementing 2 traits: Store
and StoreMut
!
In src/store/mod.rs
,
And a single optional trait, whether implementing this is all up to you!
In src/store/alter_table.rs
,
Examples - GlueSQL-js
Use SQL in web browsers!
GlueSQL-js provides 3 storage options,
- in-memory
- localStorage
- sessionStorage.
SQL Features
GlueSQL currently supports limited queries, it's in very early stage.
CREATE
with 4 types:INTEGER
,FLOAT
,BOOLEAN
,TEXT
with an optionalNULL
attribute.ALTER TABLE
with 4 operations:ADD COLUMN
,DROP COLUMN
,RENAME COLUMN
andRENAME TO
.INSERT
,UPDATE
,DELETE
,SELECT
,DROP TABLE
GROUP BY
,HAVING
- Nested select, join, aggregations ...
You can see current query supports in src/tests/*.
Other expected use cases
- Run SQL in web browsers - gluesql-js
It would be cool to make state management library using
gluesql-js
. - Add SQL layer to NoSQL databases: Redis, CouchDB...
- Build new SQL database management system
Contribution
It's very early stage, please feel free to do whatever you want to.
Only the thing you need to be aware of is...
- Except for
src/glue.rs
,src/tests/
andsrc/utils/
, there is no place to usemut
keyword.