Query A DATETIME Field In MySQL With Rust's Diesel Crate
These are scratch notes with code snippets showing what I did to get a datetime working. The model is up top with the other stuff below.
rust
use NaiveDateTime;
use *;
chrono crate
The chrono crate is used behind the scenes. It has to be added to Cargo.toml and the feature turned on for diesel . Mine looks like this :
toml
[dependencies]
chrono = "0.4.24"
diesel = { version = "2.0.0", features = ["mysql", "serde_json", "chrono"] }
dotenvy = "0.15"
Other Stuff
This is the other stuff that uses the code
sql
CREATE TABLE test2 (
id INT PRIMARY KEY,
datetime DATETIME
)
rust
use establish_connection;
use *;
use *;
use *;
rust
use *;
use dotenv;
use env;
Footnotes And References
- •
- •
- •