🐬 A MySQL/MariaDB database client for Gleam, based on mysql-otp
  • Gleam 88%
  • Erlang 12%
Find a file
feminina ba97498472
Some checks failed
Test / test (push) Failing after 8s
renamed .codeberg to .forgejo
added ref to github

added ref to github

added env var for os

added env var for os

added env var for os

added env var for os

moved env vars

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline

debug pipeline
2026-02-22 16:29:39 +01:00
.forgejo/workflows renamed .codeberg to .forgejo 2026-02-22 16:29:39 +01:00
src renamed .codeberg to .forgejo 2026-02-22 16:29:39 +01:00
test feat: Add 'date' and 'time' parameter types 2025-10-05 10:37:30 +02:00
.gitignore first commit 2024-12-30 16:26:25 +01:00
CHANGELOG.md fixed date 2025-10-12 16:37:50 +02:00
gleam.toml bump version to 1.4.0 2025-10-12 16:37:50 +02:00
LICENSE 📄 lincense added 2024-12-30 16:30:11 +01:00
LICENSE.LESSER 📝 added LICENSE.LESSER 2025-01-06 17:20:22 +01:00
manifest.toml feat: Add 'date' and 'time' parameter types 2025-10-05 10:37:30 +02:00
README.md doc: shortly write how to run tests agains mariadb database 2025-10-05 10:37:30 +02:00

shork

A MySQL / MariaDB database client for Gleam, based on MySQL-OTP. Heavily inspired by POG

import shork

pub fn main() {  
  // Start database connection
  let connection =
    shork.default_config()
    |> shork.user("root")
    |> shork.password("strong_password")
    |> shork.database("poke")
    |> shork.connect

  //  A SQL query with one parameter
  let query = "select name, hp from pokemon where id = ?"

  //  The  decoder for the returned data
  let row_decoder = {
    use name <- decode.field(0, decode.name)
    use hp <- decode.field(1, decode.int)

    decode.success(#(name, hp))
  }

  // Runs the query
  // The int 1 is given as parameter
  let assert Ok(response) = 
    shork.query(query)
    |> shork.parameter(shork.int(1))
    |> shork.returning(row_decoder)
    |> shork.execute(connection)

  response.rows
  |> should.equal([
    #("bulbasaur", 45)
  ])
}

Further documentation can be found at https://hexdocs.pm/shork.

Development

gleam run   # Run the project
gleam test  # Run the tests

To run tests, a mysql instance must be running with the following parameters:

  • host: localhost
  • port: 3306
  • user: root
  • password: root
  • database: short_test

You can start it using docker like this:

docker run -d --rm -p 3306:3306 -e MYSQL_ROOT_PASSWORD="root" -e MYSQL_DATABASE=shork_test mysql

Acknowlement

This project is kindly supported by binary butterfly.

License

GNU Lesser General Public License (LGPL) version 3 or any later version. Since the LGPL is a set of additional permissions on top of the GPL, both license texts are included in the files LICENSE and LICENSE.LESSER respectively.

In short, LGPL allows you to use the library in non-free software and software with incompatible licenses.