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 storages (sled
or memory
) 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 two reference storage options.
SledStorage
- Persistent storage engine based onsled
MemoryStorage
- Non-persistent storage engine based onBTreeMap
Installation
In your Cargo.toml
:
[]
= "0.9"
Usage
use *;
SQL Library Mode (For Custom Storage)
Installation
sled-storage
and memory-storage
features are optional, so these are not required for custom storage makers.
[]
= "0.9"
= false
= ["sorter", "alter-table", "index", "transaction"]
Four features below are also optional.
sorter
- ORDER BY support for non-indexed expressions.alter-table
- ALTER TABLE query supportindex
- CREATE INDEX & DROP INDEX, index supporttransaction
- BEGIN, ROLLBACK and COMMIT, transaction support
Usage
Two mandatory store traits to implement
Optional store traits
Use Cases
GlueSQL-js
https://github.com/gluesql/gluesql-js
Use SQL in web browsers!
GlueSQL-js provides 3 storage options,
- in-memory
- localStorage
- sessionStorage
GlueSQL Sheets
https://sheets.gluesql.com
Turn Google Sheets into a SQL database!
It uses Google Sheets as a storage.
Data is stored and updated from Google Sheets.
Other expected use cases
- Add SQL layer to NoSQL databases: Redis, CouchDB...
- Build new SQL database management system
SQL Features
GlueSQL currently supports a limited subset of queries. It's being actively developed.
CREATE TABLE
with 8 types:INTEGER
,FLOAT
,BOOLEAN
,TEXT
,DATE
,TIMESTAMP
,TIME
andINTERVAL
.ALTER TABLE
with 4 operations:ADD COLUMN
,DROP COLUMN
,RENAME COLUMN
andRENAME TO
.CREATE INDEX
,DROP INDEX
INSERT
,UPDATE
,DELETE
,SELECT
,DROP TABLE
GROUP BY
,HAVING
ORDER BY
- Transaction queries:
BEGIN
,ROLLBACK
andCOMMIT
- Nested select, join, aggregations ...
You can see tests for the currently supported queries in src/tests/*.
Contribution
There are a few simple rules to follow.
- No
mut
keywords insrc/executor
andsrc/data
. - Iterator should not be evaluated in the middle of execution layer.
- Every error must have corresponding integration test cases to generate.
(except forUnreachable-
andConflict-
error types)