(options: ConnectOptions)
| 60 | /// Add configuration options for the MySQL database |
| 61 | #[instrument(level = "trace")] |
| 62 | pub async fn connect(options: ConnectOptions) -> Result<DatabaseConnection, DbErr> { |
| 63 | let mut sqlx_opts = options |
| 64 | .url |
| 65 | .parse::<MySqlConnectOptions>() |
| 66 | .map_err(sqlx_error_to_conn_err)?; |
| 67 | use sqlx::ConnectOptions; |
| 68 | if !options.sqlx_logging { |
| 69 | sqlx_opts = sqlx_opts.disable_statement_logging(); |
| 70 | } else { |
| 71 | sqlx_opts = sqlx_opts.log_statements(options.sqlx_logging_level); |
| 72 | if options.sqlx_slow_statements_logging_level != LevelFilter::Off { |
| 73 | sqlx_opts = sqlx_opts.log_slow_statements( |
| 74 | options.sqlx_slow_statements_logging_level, |
| 75 | options.sqlx_slow_statements_logging_threshold, |
| 76 | ); |
| 77 | } |
| 78 | } |
| 79 | if let Some(f) = &options.mysql_opts_fn { |
| 80 | sqlx_opts = f(sqlx_opts); |
| 81 | } |
| 82 | let pool = if options.connect_lazy { |
| 83 | options.sqlx_pool_options().connect_lazy_with(sqlx_opts) |
| 84 | } else { |
| 85 | options |
| 86 | .sqlx_pool_options() |
| 87 | .connect_with(sqlx_opts) |
| 88 | .await |
| 89 | .map_err(sqlx_error_to_conn_err)? |
| 90 | }; |
| 91 | Ok(DatabaseConnection::SqlxMySqlPoolConnection( |
| 92 | SqlxMySqlPoolConnection { |
| 93 | pool, |
| 94 | metric_callback: None, |
| 95 | }, |
| 96 | )) |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | impl SqlxMySqlConnector { |
nothing calls this directly
no test coverage detected