Parrot โ€“ type-safe SQL in Gleam, supports SQlite, PostgreSQL and MySQL

https://news.ycombinator.com/rss Hits: 16
Summary

๐Ÿฆœ Parrot / type-safe SQL in gleam ๐Ÿšจ Exciting News Parrot got listed a community project on the sqlc website! ๐Ÿฆœ๐ŸŽ‰ Check it out here: https://docs.sqlc.dev/en/latest/reference/language-support.html Table of Contents Table of contents generated with markdown-toc Features Most of the heavy lifting features are provided by / built into sqlc, I do not aim to take credit for them. โ˜‘๏ธ Supports SQlite, PostgreSQL and MySQL. โ˜‘๏ธ Multiple queries per file. โ˜‘๏ธ Database client agnostic. โ˜‘๏ธ Utility wrappers for popular gleam database libraries (lpil/sqlight, lpil/pog). โ˜‘๏ธ Automatically pulls the schema of your database. โ˜‘๏ธ Automatically downloads sqlc binary. โ˜‘๏ธ Named parameters.*1 *1: Meaning that it infers the names of the parameters from your sql queries in the gleam function you call. for example for a query called FindUser , defined as SELECT * FROM user WHERE username = $1 , parrot will produce a function where the arguments match those column names: pub fn find_user(username: String) { ... } . If you have multiple parameters of the same data types this can avoid confusion and bugs. Usage / Getting Started Installation $ gleam add parrot Define your Queries Parrot will look for all *.sql files in any sql directory under your project's src directory. Each *.sql file can contain as many SQL queries as you want. All of the queries will compile into a single src/[project name]/sql.gleam module. Here are some links to help you start out, if you are unfamiliar with the sqlc annotation syntax: Here is an example of the file structure: โ”œโ”€โ”€ gleam.toml โ”œโ”€โ”€ README.md โ”œโ”€โ”€ src โ”‚ โ”œโ”€โ”€ app.gleam โ”‚ โ””โ”€โ”€ sql โ”‚ โ”œโ”€โ”€ auth.sql โ”‚ โ””โ”€โ”€ posts.sql โ””โ”€โ”€ test โ””โ”€โ”€ app_test.gleam Code Generation # automatically detects database & engine from env (DATABASE_URL by default) $ gleam run -m parrot # provide connection string from different environment variable $ gleam run -m parrot -- -e PG_DATABASE_URL # specify sqlite file $ gleam run -m parrot -- --sqlite < file_path > # see all options $ gleam run -m parrot h...

First seen: 2025-10-05 03:00

Last seen: 2025-10-05 18:02