pub type MariadbConnection = MysqlLikeConnection<Mariadb>;Available on crate features
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
§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 */ }Trait Implementations§
Source§impl<'b, Changes, Output> UpdateAndFetchResults<Changes, Output> for MariadbConnectionwhere
Changes: Copy + Identifiable + AsChangeset<Target = <Changes as HasTable>::Table> + IntoUpdateTarget,
Changes::Table: FindDsl<Changes::Id>,
Update<Changes, Changes>: ExecuteDsl<MariadbConnection>,
Find<Changes::Table, Changes::Id>: LoadQuery<'b, MariadbConnection, Output>,
<Changes::Table as Table>::AllColumns: ValidGrouping<()> + SelectableExpression<ReturningQuerySource<UpdateStmt, Changes::Table>>,
<<Changes::Table as Table>::AllColumns as ValidGrouping<()>>::IsAggregate: MixedAggregates<No, Output = No>,
impl<'b, Changes, Output> UpdateAndFetchResults<Changes, Output> for MariadbConnectionwhere
Changes: Copy + Identifiable + AsChangeset<Target = <Changes as HasTable>::Table> + IntoUpdateTarget,
Changes::Table: FindDsl<Changes::Id>,
Update<Changes, Changes>: ExecuteDsl<MariadbConnection>,
Find<Changes::Table, Changes::Id>: LoadQuery<'b, MariadbConnection, Output>,
<Changes::Table as Table>::AllColumns: ValidGrouping<()> + SelectableExpression<ReturningQuerySource<UpdateStmt, Changes::Table>>,
<<Changes::Table as Table>::AllColumns as ValidGrouping<()>>::IsAggregate: MixedAggregates<No, Output = No>,
Source§fn update_and_fetch(&mut self, changeset: Changes) -> QueryResult<Output>
fn update_and_fetch(&mut self, changeset: Changes) -> QueryResult<Output>
See the traits documentation.