gleam/pgo

Postgresql client

Gleam wrapper around pgo library

Types

Type that can be passed as arguments to a query.

pub external type PgType

Avaliable configuration options when starting a pool.

pub type PoolConfig {
  Host(String)
  Port(Int)
  Database(String)
  User(String)
  Password(String)
  Ssl(Bool)
  PoolSize(Int)
  QueueTarget(Int)
  QueueInterval(Int)
  IdleInterval(Int)
  Trace(Bool)
}

Constructors

  • Host(String)
  • Port(Int)
  • Database(String)
  • User(String)
  • Password(String)
  • Ssl(Bool)
  • PoolSize(Int)
  • QueueTarget(Int)
  • QueueInterval(Int)
  • IdleInterval(Int)
  • Trace(Bool)
pub type QueryCommand {
  Insert
  Update
  Select
  Delete
}

Constructors

  • Insert
  • Update
  • Select
  • Delete
pub type QueryError {
  ConstrainError(
    message: String,
    constraint: String,
    detail: String,
  )
  PgsqlError(message: String)
  WrongNumberOfArguments(expected: Int, given: Int)
  Other(Dynamic)
}

Constructors

  • ConstrainError( message: String, constraint: String, detail: String, )
  • PgsqlError(message: String)
  • WrongNumberOfArguments(expected: Int, given: Int)
  • Other(Dynamic)

Functions

pub fn bool(value: Bool) -> PgType
pub fn bytea(value: BitString) -> PgType
pub fn float(value: Float) -> PgType
pub fn int(value: Int) -> PgType
pub fn null() -> PgType
pub fn nullable(
  value: Option(a),
  mapper: fn(a) -> PgType,
) -> PgType
pub fn query(
  pool: Atom,
  sql: String,
  arguments: List(PgType),
) -> Result(tuple(QueryCommand, Int, List(Dynamic)), QueryError)

Run a SQL query with the given arguments

pub external fn start_link(
  Atom,
  List(PoolConfig),
) -> Result(Pid, Dynamic)
pub fn text(value: String) -> PgType
pub fn url_config(
  database_url: String,
) -> Result(List(PoolConfig), Nil)

Parse a database url into an option list that can be used to start a pool.