PGL
pgl is a PostgreSQL client written in Gleam.
Features
- Implementation of PostgreSQL wire protocol
- SSL support
SCRAM-SHA-256Authentication- Connection pooling provided by
db_pool - PostgreSQL data types provided by
pg_value - Transaction support
- Savepoint support
- Pipelining
Example
import pgl
import pg_value as value
pub fn main() {
let assert Ok(conf) =
"postgres://user:pass@db:5432/pgl_db"
|> pgl.from_url
let db = pgl.new(conf)
let assert Ok(_) = pgl.start(db)
let assert Ok(queried) =
{
use conn <- pgl.with_connection(db)
"SELECT * FROM users WHERE id=$1"
|> pgl.sql
|> pgl.params([value.int(1000)])
|> pgl.query(conn)
}
pgl.shutdown(db)
}
Installation
gleam add pgl
Acknowledgements
Early iterations of this package were based on pgo and its influence remains. pog and postgrex were also helpful in writing this package.