Starting with sqlite and diesel.rs

i want to learn how to use diesel.rs with sqlite, please recommend any tutorial/video/article/etc.
btw: I know almost nothing about sqlite or dbms in general (just know the basic syntax as it was taught to us in school), I have already installed using

cargo install diesel_cli

and idk how to set database URL env variable as sqlite is serverless (google helped me a lot).
i tried the "migration generate" command from the getting started page of diesel.rs, I didn't understand it though ......
i want to use sqlite for a simple arduino smart alarm kind of project (just behind a vague idea, a lot in WIP), so tutorials for setting diesel up with rocket.rs and actix is very confusing ..... please help .... thank you in advance

It's right there in the docs:

Unlike other backends, "connection URLs" for SQLite are file paths, URIs, or special identifiers like :memory:

So you can just specify the (full) path to your SQLite database file as the value of the URL envvar.

By the way, if you don't know how to use SQLite, don't try to deep dive into Diesel just yet. It's a complicated beast, and especially for an embedded project, I'm not sure it's worth the effort. It provides a lot of abstraction, but if you are not familiar with database management, that amount of abstraction can easily turn into obscurity and a pain when trying to debug it.

First of all, try experimenting with SQLite through the REPL (interactive shell) it provides, in order to explore its capabilities. Then have a look at the rusqlite crate as well, which is a Rust-style, low-level wrapper around the C API of SQLite.

2 Likes

Thank you

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.