-
|
Beta Was this translation helpful? Give feedback.
Answered by
Xide
Mar 1, 2021
Replies: 1 comment 1 reply
-
Hey ! Here is the implementation i am using to do this (with MySQL, but the same should be usable with other backends): use sqlx::mysql::{MySqlPool, MySqlPoolOptions, MySqlConnectOptions};
use std::str::FromStr;
use std::time::Duration;
use sqlx::ConnectOptions;
pub async fn connect(url: &str) -> Result<(), sqlx::Error> {
let mut connection_options = MySqlConnectOptions::from_str(url)?;
connection_options
.log_statements(log::LevelFilter::Debug)
.log_slow_statements(log::LevelFilter::Warn, Duration::from_secs(1));
let pool = MySqlPoolOptions::new()
.connect_with(connection_options)
.await?;
Ok(())
} Here is the documentation of those functions : https://docs.rs/sqlx/0.5.1/sqlx/trait.ConnectOptions.html |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
jlkiri
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey !
Here is the implementation i am using to do this (with MySQL, but the same should be usable with other backends):
Here is t…