4 ms·
Thanks for trying out Rocket! There are a couple of examples in Rocket's repository that illustrate how to use Rocket with a database. The more complete of the
by sbenitez 10y ago
Thanks for trying out Rocket! There are a couple of examples in Rocket's repository that illustrate how to use Rocket with a database. The more complete of the two is the todo example [0]. This uses Diesel as its ORM alongside managed state to maintain a pool of database connections. The second example of the two uses raw SQLite without a connection pool [1]. It's meant to be a bare bones illustration of using a database with Rocket.
Managed state is a feature specifically designed to help with this kind of thing. That being said, I still think Rocket can do more to abstract away database connections. I'm tracking improvements on this front in GitHub issue #167 [2].
[0]: https://github.com/SergioBenitez/Rocket/tree/master/examples/todo https://github.com/SergioBenitez/Rocket/tree/master/examples...
[1]: https://github.com/SergioBenitez/Rocket/blob/master/examples/raw_sqlite https://github.com/SergioBenitez/Rocket/blob/master/examples...
[2]: https://github.com/SergioBenitez/Rocket/issues/167 https://github.com/SergioBenitez/Rocket/issues/167
- danaliv 10y agoThanks so much for the helpful reply! I should've noted that I haven't actually tried Rocket. :) It was a couple other frameworks that I'd played with, all of which seemed to go shrug, not our concern when the question of managed state came up. I'll give Rocket a try and see if I have better luck.
- bjz_ 10y agoI was actually going to use `lazy_static!` for this! Good to see a nicer solution is now here. :)