pub type MariadbConnection = MysqlLikeConnection<Mariadb>;mariadb_backend and mariadb only.Expand description
A connection to a Mariadb database. Connection URLs should be in the form
mariadb://[user[:password]@]host/database_name[?unix_socket=socket-path]
hostcan be an IP address or a hostname. If it is set tolocalhost, a connection will be attempted through the socket at/tmp/mysql.sock. If you want to connect to a local server via TCP (e.g. docker containers), use0.0.0.0or127.0.0.1instead.unix_socketexpects the path to the unix socket
Errors carry the SQLSTATE the server or client library reports in
DatabaseErrorInformation::sqlstate,
including custom codes raised with
SIGNAL.
The server reports HY000 for errors without a specific SQLSTATE, as
described at https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/programmatic-compound-statements-diagnostics/sqlstate.
§Supported loading model implementations
As MariadbConnection only supports a single loading mode implementation
it is not required to explicitly specify a loading mode
when calling RunQueryDsl::load_iter()
or LoadConnection::load
§DefaultLoadingMode
MariadbConnection only supports a single loading mode, which loads
values row by row from the result set.
use diesel::connection::DefaultLoadingMode;
{ // scope to restrict the lifetime of the iterator
let iter1 = users::table.load_iter::<(i32, String), DefaultLoadingMode>(connection)?;
for r in iter1 {
let (id, name) = r?;
println!("Id: {} Name: {}", id, name);
}
}
// works without specifying the loading mode
let iter2 = users::table.load_iter::<(i32, String), _>(connection)?;
for r in iter2 {
let (id, name) = r?;
println!("Id: {} Name: {}", id, name);
}This mode does not support creating multiple iterators using the same connection.
use diesel::connection::DefaultLoadingMode;
let iter1 = users::table.load_iter::<(i32, String), DefaultLoadingMode>(connection)?;
let iter2 = users::table.load_iter::<(i32, String), DefaultLoadingMode>(connection)?;
for r in iter1 {
let (id, name) = r?;
println!("Id: {} Name: {}", id, name);
}
for r in iter2 {
let (id, name) = r?;
println!("Id: {} Name: {}", id, name);
}Aliased Type§
pub struct MariadbConnection { /* private fields */ }