1
1
Fork
You've already forked shork
0
🐬 A MySQL/MariaDB database client for Gleam, based on mysql-otp
  • Gleam 88%
  • Erlang 12%
SLM 3aafc80b76
All checks were successful
Test / test (push) Successful in 47s
chore: Fix CI pipeline & tests
There were two issues:
- The environment variables for the whole pipeline were defined at
 the wrong position (in "on" instead of the YML root), thus the DB
 password was always empty, which prevented the MySQL service from
 starting properly. Unfortunately, Forgejo's error reporting for
 this sort of stuff is pretty lackluster, so the only symptom was
 that the "mysql" host name was not resolved properly.
 -> Fixed by removing the indentation of the "env" key.
- Debugging this was made more difficult by the second problem: The
 tests did not specify a host name to connect to. Instead they
 defaulted to "localhost", which hid the non-existing domain error
 and replaced it with a connection refused error.
 -> Fixed my explicitly setting the DB host in the tests.
2026年05月01日 17:40:11 +02:00
.forgejo/workflows chore: Fix CI pipeline & tests 2026年05月01日 17:40:11 +02:00
src renamed .codeberg to .forgejo 2026年02月22日 16:29:39 +01:00
test chore: Fix CI pipeline & tests 2026年05月01日 17:40:11 +02:00
.gitignore fix truncates, add compose file, update deps 2026年05月01日 13:09:02 +02:00
CHANGELOG.md fix truncates, add compose file, update deps 2026年05月01日 13:09:02 +02:00
compose.yml fix truncates, add compose file, update deps 2026年05月01日 13:09:02 +02:00
gleam.toml fix truncates, add compose file, update deps 2026年05月01日 13:09:02 +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 fix truncates, add compose file, update deps 2026年05月01日 13:09:02 +02:00
README.md fix truncates, add compose file, update deps 2026年05月01日 13:09:02 +02:00

shork

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


importshorkpubfnmain(){// Start database connection
letconnection=shork.default_config()|>shork.user("root")|>shork.password("strong_password")|>shork.database("poke")|>shork.connect// A SQL query with one parameter
letquery="select name, hp from pokemon where id = ?"// The decoder for the returned data
letrow_decoder={usename<-decode.field(0,decode.name)usehp<-decode.field(1,decode.int)decode.success(#(name,hp))}// Runs the query
// The int 1 is given as parameter
letassertOk(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 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

alternatively:

docker compose up

Acknowledgement

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.