[−][src]Struct rbatis_core::mysql::MySqlConnection
An asynchronous connection to a [MySql] database.
The connection string expected by MySqlConnection should be a MySQL connection
string, as documented at
https://dev.mysql.com/doc/refman/8.0/en/connecting-using-uri-or-key-value-pairs.html#connecting-using-uri
TLS Support (requires tls feature)
This connection type supports some of the same flags as the mysql CLI application for SSL
connections, but they must be specified via the query segment of the connection string
rather than as program arguments.
The same options for --ssl-mode are supported as the ssl-mode query parameter:
https://dev.mysql.com/doc/refman/8.0/en/connection-options.html#option_general_ssl-mode
mysql://<user>[:<password>]@<host>[:<port>]/<database>[?ssl-mode=<ssl-mode>[&ssl-ca=<path>]]
where
ssl-mode = DISABLED | PREFERRED | REQUIRED | VERIFY_CA | VERIFY_IDENTITY
path = percent (URL) encoded path on the local machine
If the tls feature is not enabled, ssl-mode=DISABLED and ssl-mode=PREFERRED are no-ops and
ssl-mode=REQUIRED, ssl-mode=VERIFY_CA and ssl-mode=VERIFY_IDENTITY are forbidden
(attempting to connect with these will return an error).
If the tls feature is enabled, an upgrade to TLS is attempted on every connection by default
(equivalent to ssl-mode=PREFERRED). If the server does not support TLS (because --ssl=0 was
passed to the server or an invalid certificate or key was used:
https://dev.mysql.com/doc/refman/8.0/en/using-encrypted-connections.html)
then it falls back to an unsecured connection and logs a warning.
Add ssl-mode=REQUIRED to your connection string to emit an error if the TLS upgrade fails.
However, like with mysql the server certificate is not checked for validity by default.
Specifying ssl-mode=VERIFY_CA will cause the TLS upgrade to verify the server's SSL
certificate against a local CA root certificate; this is not the system root certificate
but is instead expected to be specified as a local path with the ssl-ca query parameter
(percent-encoded so the URL remains valid).
If you're running MySQL locally it might look something like this (for VERIFY_CA):
mysql://root:password@localhost/my_database?ssl-mode=VERIFY_CA&ssl-ca=%2Fvar%2Flib%2Fmysql%2Fca.pem
%2F is the percent-encoding for forward slash (/). In the example we give /var/lib/mysql/ca.pem
as the CA certificate path, which is generated by the MySQL server automatically if
no certificate is manually specified. Note that the path may vary based on the default my.cnf
packaged with MySQL for your Linux distribution. Also note that unlike MySQL, MariaDB does not
generate certificates automatically and they must always be passed in to enable TLS.
If ssl-ca is not specified or the file cannot be read, then an error is returned.
ssl-ca implies ssl-mode=VERIFY_CA so you only actually need to specify the former
but you may prefer having both to be more explicit.
If ssl-mode=VERIFY_IDENTITY is specified, in addition to checking the certificate as with
ssl-mode=VERIFY_CA, the hostname in the connection string will be verified
against the hostname in the server certificate, so they must be the same for the TLS
upgrade to succeed. ssl-ca must still be specified.
Trait Implementations
impl Connect for MySqlConnection[src]
fn connect<T>(url: T) -> BoxFuture<'static, Result<MySqlConnection>> where
T: TryInto<Url, Error = ParseError>,
Self: Sized, [src]
T: TryInto<Url, Error = ParseError>,
Self: Sized,
impl Connection for MySqlConnection[src]
fn close(self) -> BoxFuture<'static, Result<()>>[src]
fn ping(&mut self) -> BoxFuture<'_, Result<()>>[src]
fn begin(self) -> BoxFuture<'static, Result<Transaction<Self>>> where
Self: Sized, [src]
Self: Sized,
impl Executor for MySqlConnection[src]
type Database = MySql
The specific database that this type is implemented for.
fn execute<'e, 'q: 'e, 'c: 'e, E: 'e>(
&'c mut self,
query: E
) -> BoxFuture<'e, Result<u64>> where
E: Execute<'q, Self::Database>, [src]
&'c mut self,
query: E
) -> BoxFuture<'e, Result<u64>> where
E: Execute<'q, Self::Database>,
fn cursor<'q, E>(&mut self, query: E) -> MySqlCursor<'_, 'q> where
E: Execute<'q, Self::Database>, [src]
E: Execute<'q, Self::Database>,
impl<'c> RefExecutor<'c> for &'c mut MySqlConnection[src]
type Database = MySql
fn fetch_by_ref<'q, E>(self, query: E) -> MySqlCursor<'c, 'q> where
E: Execute<'q, Self::Database>, [src]
E: Execute<'q, Self::Database>,
Auto Trait Implementations
impl RefUnwindSafe for MySqlConnection
impl Send for MySqlConnection
impl Sync for MySqlConnection
impl Unpin for MySqlConnection
impl UnwindSafe for MySqlConnection
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,