View Source GlueSQL (gluesql v0.15.0)

GlueSQL is a SQL database library for Elixir.
This repository is an Elixir binding of the original Rust library gluesql-rs.

Just another SQL database library?

Various Storage Engines

GlueSQL supports various storages(pre-existing databases, files, etc), already implemented in gluesql-rs.

The list of supported storages are:

  • [x] In-Memory
  • [ ] Redis
  • [ ] MongoDB Storage
  • [ ] JSON file
  • [ ] CSV file
  • [ ] IDB
  • [ ] sled, a high-performant database written with Rust.

...and much more will be supported in future.
(Unchecked items are yet bound to GlueSQL Elixir library).

With-or-without schema

Unlike most of the SQL databases, GlueSQL supports not only schema-enabled queries but also schema-less queries.

It's better understood by reading the example below.

Example

alias GlueSQL.Storages.MemoryStorage
alias GlueSQL

# Create SQL database with memory storage
db =
  MemoryStorage.new()
  |> GlueSQL.glue_new()

# Create table with schema
GlueSQL.query(db, "CREATE TABLE users (id INTEGER, name STRING);")

# Insert values
GlueSQL.query(db, """
        INSERT INTO users VALUES
        (1, "Hoon Wee"),
        (2, "Eunbee Cho");
        """)

# We can also create table WITHOUT schema
GlueSQL.query(db, "CREATE TABLE friends;")

# Insert values
GlueSQL.query(db, """
        INSERT INTO friends VALUES
        ('{ "name": "Hoon Wee" }'),
        ('{ "username": "Eunbee Cho", "age": 12 }');
        """)

Installation

If available in Hex, the package can be installed by adding gluesql to your list of dependencies in mix.exs:

def deps do
  [
    {:gluesql, "~> 0.1.0"}
  ]
end

Summary

Functions

Create a GlueSQL database with given storage engine.

Execute given query for database. SQL query should be provided as string format.

Functions

Create a GlueSQL database with given storage engine.

Example: Create a SQL database that runs on in-memory storage.

alias GlueSQL.Storages.MemoryStorage

db =
  MemoryStorage.new()
  |> GlueSQL.glue_new()

Execute given query for database. SQL query should be provided as string format.

Example: Create tables (with-or-without schema).

 GlueSQL.query(db, """
     CREATE TABLE Foo (id INTEGER); # schema
     CREATE TABLE Bar; #schema-less
     """)