-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use system time_zone in MySqlConnection? #329
Comments
See #263 (comment) for a potential solution to amend what SQLx is doing on start-up or for general purpose execution. Another idea is to allow setting system variables via query parameters. The Go MySQL driver allows this.
Currently, there is no good answer here. #263 is probably a minimum to fix issues like this. |
Here is my dirty way to write local timezone datetime. // Assume local timezone is +08:00
// FIXME Local+naive_local()=+16 timezone!!!
let datetime = chrono::Local::now().naive_local();
sqlx::query("INSERT INTO trades (created_at) VALUES (?);")
.bind(datetime)
.execute(&pool)
.await
.unwrap(); MySqlConnection(0) + NaiveDateTime(+16) = local timezone(+8) |
Let's keep this open until there is a solution here. |
For properly decoding Or I guess the onus is on the user if they decide to set the timezone to non-UTC to only use |
Hello, I have similar problem, I want my result field DateTime, but query_as didn't accept it. |
How is this going? When selecting NOW() on sqlx I get a utc+0 timestamp, when using mysql terminal I get utc+11. This causes havoc for my views for example when they operate on datetimes within functions that I have made that assume a +11. |
This is best answer!!!! |
c
Setting a session-level timezone via uri seems generic and reasonable. |
I also encountered this problem, now I get the time all through rust |
see #3418 |
I want to use local/system timezone in MySqlPool.
But each MySqlConnection execute
SET time_zone = '+00:00';
after it is established.sql-core/src/connection.rs:317
Potential Solutions
Execute
SET time_zone = SYSTEM;
Before insert/update datetime value,but
SET time_zone
andInsert
maybe using different connection.The text was updated successfully, but these errors were encountered: