shork
Types
pub type Connection
pub type QueryError {
UnexpectedResultType(List(decode.DecodeError))
ServerError(Int, String)
}
Constructors
-
UnexpectedResultType(List(decode.DecodeError))
The rows returned by the database could not be decoded using the supplied dynamic decoder.
-
ServerError(Int, String)
The server returned a error during processing the query.
The names of the column names and the rows returned by the query.
pub type Returned(t) {
Returned(column_names: List(String), rows: List(t))
}
Constructors
-
Returned(column_names: List(String), rows: List(t))
pub type TransactionError {
TransactionQueryError(QueryError)
TransactionRolledBack(String)
}
Constructors
-
TransactionQueryError(QueryError)
One query inside a query returned a error.
-
TransactionRolledBack(String)
The transaction rolled back as an result of an error inside the transaction.
Values
pub fn connection_timeout(
config: Config,
query_timeout: Int,
) -> Config
The maximum time to spend on connect.
(default: 3000)
pub fn execute(
query query: Query(t),
on connection: Connection,
) -> Result(Returned(t), QueryError)
Run a query against a MySQL/MariaDB database.
pub fn keep_alive(config: Config, keep_alive: Bool) -> Config
Whether to send keep alive messages for used connections.
(default: False)
pub fn log_slow_queries(
config: Config,
log_slow_queries: Bool,
) -> Config
Whether to log queries that got as slow query from the server.
(default: False)
pub fn log_warnings(config: Config, log_warnings: Bool) -> Config
Whether to fetch warnings and log them using error_logger.
(default: False)
pub fn parameter(query: Query(t), parameter: Value) -> Query(t)
Push a new parameter value for the query.
pub fn query(sql: String) -> Query(Nil)
Set the decoder to use for the type of row returned by executing this query.
If the decoder is unable to decode the row value then query will return an error.
pub fn query_cache_time(
config: Config,
query_cache_time: Int,
) -> Config
The minimum number of milliseconds to cache prepared statements used for parametrized queries with query.
(default: 1000)
pub fn query_timeout(
config: Config,
query_timeout: Int,
) -> Config
Default time to wait for a query to execute.
(default: 5000)
pub fn returning(
query: Query(t1),
decoder: decode.Decoder(t2),
) -> Query(t2)
Create a new query to use with the execute
, returning
and parameters
function.
pub fn timeout(query: Query(t), timeout: Int) -> Query(t)
Use a custom timeout for the query. The timeout give is given in ms.
pub fn transaction(
connection: Connection,
callback cb: fn(Connection) -> Result(t, e),
) -> Result(t, TransactionError)