Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arthurpaulino/leanmysql
A MySQL API for Lean 4
https://github.com/arthurpaulino/leanmysql
lean4 mysql
Last synced: 9 days ago
JSON representation
A MySQL API for Lean 4
- Host: GitHub
- URL: https://github.com/arthurpaulino/leanmysql
- Owner: arthurpaulino
- License: apache-2.0
- Created: 2021-11-23T04:23:45.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-03-11T16:58:44.000Z (over 2 years ago)
- Last Synced: 2024-11-01T15:36:44.530Z (16 days ago)
- Topics: lean4, mysql
- Language: Lean
- Homepage:
- Size: 112 KB
- Stars: 17
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LeanMySQL
This Lean 4 package provides an API for the MySQL database.
Usage example:
```lean
import LeanMySQLdef main : IO Unit := do
let mysql ← MySQL.mk
IO.println $ mysql.version
mysql.login "localhost" "root" "root"
mysql.createDB "test_db"
mysql.useDB "test_db"mysql.createTable "job" [
("id", "INT PRIMARY KEY"),
("job_name", "VARCHAR(255)")
]
mysql.insertIntoTable "job" [1, "Computer Scientist"]
mysql.insertIntoTable "job" [2, "Mathematician"]mysql.createTable "person" [
("id", "INT PRIMARY KEY"),
("name", "VARCHAR(255)"),
("age", "INT"),
("height", "FLOAT"),
("job_id", "INT"),
("country_id", "INT")
]
mysql.insertIntoTable "person" [1, "Alice", 20, 1.72, 1, 1]
mysql.insertIntoTable "person" [2, "Bob", 21, 1.64, 2, 3]
mysql.insertIntoTable "person" [3, "Craig", 22, 1.76, NULL, 2]let df ← mysql.query $
SELECT name, age, height, job_name
FROM person LEFT JOIN job ON person.job_id = job.id
WHERE person.age > 20IO.println $ df
mysql.close
```The example above prints out:
```
8.0.28
| name|age|height| job_name|
|-------|---|------|---------------|
| 'Bob'| 21| 1.64|'Mathematician'|
|'Craig'| 22| 1.76| NULL|
```## What's next?
* Allow queries on the `FROM` clause (nested queries)
* Expand the implicit join so it can accept multiple sources, not just twoFeel free to contribute! :D