GlueSQL
SQL Database Engine as a Library
GlueSQL is a SQL database library written in Rust. It provides a parser (sqlparser-rs), execution layer, and optional storage (sled) packaged into a single library. Developers can choose to use GlueSQL to build their own SQL database, or as an embedded SQL database using the default storage engine.
Standalone Mode
You can use GlueSQL as an embedded SQL database. GlueSQL provides sled as a default storage engine.
Installation
In your Cargo.toml
:
[]
= "0.4"
Usage
use ;
SQL Library Mode (For Custom Storage)
Installation
sled-storage
is optional. So in Cargo.toml
:
[]
= { = "0.4", = false, = ["alter-table"] }
# alter-table is optional.
# If your DB does not have plan to support ALTER TABLE, then use this below.
= { = "0.4", = false }
Usage
There are two required 2 traits for using GlueSQL: Store
and StoreMut
.
In src/store/mod.rs
,
.. there is also a single, optional trait:
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 a limited subset of queries. It's being actively developed.
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 tests for the currently supported queries in src/tests/*.
Other expected use cases
- Run SQL in web browsers - gluesql-js
It would be cool to make a state management library using
gluesql-js
. - Add SQL layer to NoSQL databases: Redis, CouchDB...
- Build new SQL database management system
Contribution
GlueSQL is still in the very early stages of development. Please feel free to contribute however you'd like! The only thing you need to be aware of is...
- Except for
src/glue.rs
,src/tests/
andsrc/utils/
, using themut
keyword is discouraged.