gleam/pgo
Postgresql client
Gleam wrapper around pgo library
Types
PgType
Type that can be passed as arguments to a query.
pub external type PgType
PoolConfig
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)
QueryCommand
pub type QueryCommand {
Insert
Update
Select
Delete
}
Constructors
-
Insert -
Update -
Select -
Delete
QueryError
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
bool
pub fn bool(value: Bool) -> PgType
bytea
pub fn bytea(value: BitString) -> PgType
float
pub fn float(value: Float) -> PgType
int
pub fn int(value: Int) -> PgType
null
pub fn null() -> PgType
nullable
pub fn nullable( value: Option(a), mapper: fn(a) -> PgType, ) -> PgType
query
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
start_link
pub external fn start_link( Atom, List(PoolConfig), ) -> Result(Pid, Dynamic)
text
pub fn text(value: String) -> PgType
url_config
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.