5 ms·
What's the current state of database access? Last I looked a while back Diesel was really cool, but didn't play nice w/ Async.
by cschneid 3y ago
What's the current state of database access? Last I looked a while back Diesel was really cool, but didn't play nice w/ Async.
- satvikpendem 3y agoI use Prisma Client Rust [0], coming from the Node.js world, it works great. Some people like to use sqlx though, I'm not too big into writing SQL for every little thing. [0] https://github.com/Brendonovich/prisma-client-rust https://github.com/Brendonovich/prisma-client-rust
- phaer 3y agoHaven't used it myself, but https://github.com/SeaQL/sea-orm https://github.com/SeaQL/sea-orm seems to be popular in some communities and async
- lwhsiao 3y agoSQLx [1] is commonly recommended. It has the nice feature that your queries can be verified at compile time. [1]: https://github.com/launchbadge/sqlx https://github.com/launchbadge/sqlx
- mattrighetti 3y agoThe first time I used SQLx I was completely blown away by this. It’s an incredibly useful feature that I’ve never seen before and now I’m actually spoiled by it! The only downside is that you have to install sqlx-cli and you have to run a couple of special commands to make your binary compile offline or on CI/CD where you don’t provide that database connection.
- Spartan-S63 3y agoDiesel now has an official async adapter: https://crates.io/crates/diesel-async https://crates.io/crates/diesel-async
- telios 3y agoI've used diesel async for personal projects, and while it does work seamlessly with diesel at times, there are some rough edges - I ran into an odd issue where the order of imports from the base diesel package and diesel async mattered, and it would compile with one above the other, but not the other way around.
- davidatbu 3y agoI've also used with diesel async for personal projects, and I have ran into no rough edges at all, fwiw.
- redman25 3y agoAsync is not necessarily as useful for database connections since connection counts will generally be in the 10s and handled with a thread pool. It's pretty low overhead to just use pooling.
- unshavedyak 3y agoYea but you still want a good async interface if you're already using async, even if it's mocked over an underlying threadpool. Otherwise you have to wrap all your DB clients in your own adhoc async wrappers which feels kinda bad, imo.
- laurencerowe 3y agoIt’s frustrating there seems to be no good threaded web server for Rust given how uniquely great Rust is at threading. You can adapt from async to sync but there is a definite complexity tax with all the pinning plus the runtime cost of the extra pinning. Async is great for more proxy like use cases though.
- laurencerowe 3y ago*runtime cost of the extra copying.