gmysql
Types
pub type Config {
Config(
host: String,
port: Int,
user: Option(String),
password: Option(String),
database: String,
connection_mode: ConnectionMode,
connection_timeout: Int,
keep_alive: Int,
)
}
Constructors
-
Config( host: String, port: Int, user: Option(String), password: Option(String), database: String, connection_mode: ConnectionMode, connection_timeout: Int, keep_alive: Int, )
pub type Connection
pub type ConnectionMode {
Synchronous
Asynchronous
Lazy
}
Constructors
-
Synchronous
-
Asynchronous
-
Lazy
pub type Error {
ServerError(Int, BitArray)
UnknownError(Dynamic)
DecodeError(dynamic.DecodeErrors)
}
Constructors
-
ServerError(Int, BitArray)
-
UnknownError(Dynamic)
-
DecodeError(dynamic.DecodeErrors)
pub type TransactionError(a) {
FunctionError(a)
OtherError(Dynamic)
}
Constructors
-
FunctionError(a)
-
OtherError(Dynamic)
Functions
pub fn default_config() -> Config
pub fn query(
connection: Connection,
query: String,
params: List(Param),
timeout: Int,
decoder: fn(Dynamic) -> Result(a, List(DecodeError)),
) -> Result(a, Error)
pub fn with_connection(
config: Config,
with function: fn(Connection) -> a,
) -> Result(a, Dynamic)
pub fn with_transaction(
connection: Connection,
retry retries: Int,
with function: fn(Connection) -> Result(a, b),
) -> Result(a, TransactionError(b))
Execute a function within a transaction. If the function throws or returns an error, it will rollback. You can nest this function, which will create a savepoint.