Rust & SQL Databases (With Diesel)

preview_player
Показать описание
Learn some general best practices for interacting with SQL databases, and walk through how to use Diesel for implementing these practices in your Rust application.

00:00 Introduction
01:22 Rustflix Demo
01:32 Diesel CLI
02:24 .env
02:50 Diesel Setup
03:04 Schema Migrations
07:15 Establishing A Database Connection
08:05 Video Model & Diesel Model Macros
10:05 Creating, Updating, and Showing Videos
13:20 Verifying Video Operations
13:54 Thoughts On Productionizing

Stuff I use to make these videos - I absolutely love all of these products. Using these links is an easy way to support the channel, thank you so much if you do so!!!

Рекомендации по теме
Комментарии
Автор

Such a fun way to learn Rust by watching these. Totally sold on Rust at this point. A video about Tauri would be very interesting

tobias
Автор

Really great video! Diesel always seemed very complicated, but your explanations and code were very good. As a suggestion for future video, maybe SQLX can provide a good comparison ground for those who are deciding which one to use. Also, I was wondering if there's an ORM that has async support. That can also make a nice comparison video.

nscarlos
Автор

Amazing content. I especially appreciate the gotchas that you point out in these videos. Each one probably saves dozens of folks hours of time.

palekenyanful
Автор

Thanks for summarizing [diesel] and how it was designed. I was about to use use rust to translate sql files. [diesel] is very complex and time consuming. You have to be a seasoned programming veteran to use this. I wrote script for making a cargo project, just in case I need to use it in the future. But man there is no way a regular programmer is going to get this. I am shocked that diesel only supports postgresql, mysql, and sqlite. I was looking for rust database drivers for mission critical million dollar businesses which usually only use oracle, sybase, db2, postgresql, mssql, and (sometimes) terrcotta+snowflake. You saved me about a week worth of research that would have been hopeless aim. I still use diesel + rust just for practice and see if it can handle all these concurrent databases I have. Now I have to go find graph database drivers for rust to get a big picture of where rust is working with. Rust is in a weird place.

complexity
Автор

this is great for my project of making a custom server for a game! i really needed help learning sql and rust structs

reidlab
Автор

By far the best tutorial i found to tNice tutorials in a short ti

frank
Автор

Like always, you make great content! Diesel is not easy to understand you made it quite simple. However, I don't think diesel would be a good great if you have a complex db with a lot of tables. I wish it had that db-first approach, where you create the db first and then generate the Rust codes from it. I'm learning a lot from your videos. So keep it up. Thanks.

anuradhaamarasinghe
Автор

Great video!!! I'd love it if you did a video on SeaORM. It's an asynchronous ORM built on top of sqlx. It has support for Postgres, MySQL and SQLite, and also migrations. I tried to use it, but I couldn't understand the documentation :D.

maxijoker
Автор

Please keep in mind, you can use SQLx and a repository pattern (or something alike) to abstract away your sql. As powerful ORMs are to prototype and for simple CRUD, as big of a pain in the back they can become when you introduce complexity!

danieltoth
Автор

Glad I found this channel. A gold mine.

AwakeningofAI
Автор

Consistently great videos, thank you so much!

NeotenicApe
Автор

Truly an awesome channel, keep it up!

re_allyedge
Автор

Had a thought regarding the language. How come we don't have "trait level instance variables"? I often wondered this in C# and Java as well (at interface definition) - you can have properties, but you have to implement OC - and thus are wrappers (overhead). I think it would make sense for methods in same trait to share data on the instance (it's not that they can't now - using struct variables, but the organization is all one bucket) Any thoughts? I know we're not "instantiating a trait" - but there's no reason the trait level data can't be mixed in via the trait (and those variables getting allocated upon struct instantiation).
It would be a nice way of knowing immediately what the variable was related to - under the hood, they can "merge" into the struct's definition if needed.
The variables would need to be "per trait implementation" in case it was implemented generically several times.
This would further enhance the "interface segregation" concept a bit imo, cause not only can you keep them clean by having small interfaces, but also by keeping data related to that interface (trait) tied directly to it.
Maybe the top of "impl" block (<<<< GENIUS PART, RIGHT HERE) itself would be a place you define variables to be shared by your trait implementation. The lines right underneath "impl" start line, up until first method, define all the variables you want with default values you want. All just a guise of course (for struct vars)
That way, keeps the trait flexible (by not defining any data structure at trait definition level), but keeps the related data near the impl ; then upon compilation, gets merged into struct.
Additionally, those variables (by default anyways) would be constricted to be only being accessible by methods in that impl (by the compiler) - GENIUS !
Then we update rls to only show variables that are accessible from this viewpoint. Instance vars show both struct vars and vars in the impl block currently in (but not vars defined in other impls) - if in an impl, otherwise just struct.
Then we go to the White House !

Total Benefits:
Enhanced cohesiveness - #1 esp. for large code bases
Better access control (don't touch my traits vars)
Better ergonomics (rls doesn't show "everything")

Sorry to be "BOY GENIUS" today - it just happens sometimes. I slept too well last night.

jeffg
Автор

is there support for databases like teradata or microsoft sql server? I know there is a oracle rust lib, but not sure as to its integration with diesel?

chucksneedmoreland
Автор

Can you make a video about calling APIs from Rust and parse the response as JSON? As silly as it sounds but I've seriously been struggling with that, going from the documentation to vscode back and forth

wtfdoiputhere
Автор

Beautiful this Lang. Im study and study and study this!

renatocunha
Автор

Do you know a rust library to implement a GUI?
Edit: would be nice to expand this project with more functionalities and some GUI.

johnnysummers
Автор

Thanks so much for making these videos!

tylerhanson
Автор

Simply amazing, I got the Gist of diesel with Rust, Do you any plans to make a video using Rust crates which are available for cloud technologies, That gonna be huge help.

bjugdbjk
Автор

i found the diesel documentation not so easy, this video instead is gold.
the normal way diesel works (My program structures -> Db structure) is the opposite that i saw it's used (i already have a db in my company, so diesel have to read the db structures and create structs)

massimommm