sfackler / r2d2

A generic connection pool for Rust
Apache License 2.0
1.51k stars 82 forks source link

How to set timezone when linking #128

Closed januwA closed 2 years ago

januwA commented 2 years ago

I'm using diesel, but the timezone is always set wrong every time. I want to set the timezone every time I link

diesel = { version = "1.4.4", features = ["mysql", "r2d2", "chrono", "numeric"] }

like sqlx

    let db_pool = web::Data::new(
        sqlx::mysql::MySqlPoolOptions::new()
            .max_connections(5)
            .after_connect(|conn| {
                Box::pin(async move {
                    conn.execute("set time_zone = '+8:00'").await?;
                    Ok(())
                })
            })
            .connect(&bd_url)
            .await
            .expect("链接数据库失败"),
    );

I set the default time zone in the mysql configuration file, but it still doesn't work after the link

[mysqld]
default-time_zone = '+8:00'

all i want to set the timezone on every link

thanks ❤️

sfackler commented 2 years ago

This is a question for the developers of the mysql library.