1
0
mirror of https://github.com/actix/examples synced 2024-11-27 07:52:57 +01:00
examples/basics/todo
2022-02-06 08:19:35 +00:00
..
migrations use sqlite in basics/todo 2022-02-06 07:55:51 +00:00
src fix db/basic 2022-02-06 08:19:35 +00:00
static Restructure folders (#411) 2021-02-26 00:57:58 +00:00
templates Restructure folders (#411) 2021-02-26 00:57:58 +00:00
.env use sqlite in basics/todo 2022-02-06 07:55:51 +00:00
.gitignore use sqlite in basics/todo 2022-02-06 07:55:51 +00:00
Cargo.toml use sqlite in basics/todo 2022-02-06 07:55:51 +00:00
README.md use sqlite in basics/todo 2022-02-06 07:55:51 +00:00
sqlx-data.json use sqlite in basics/todo 2022-02-06 07:55:51 +00:00

Todo

A simple Todo project using a SQLite database.

Prerequisites

  • SQLite 3

Change Into This Project Sub Directory

All instructions assume you have changed into this folder:

cd basics/todo

Set Up The Database

Install the sqlx command-line tool with the required features:

cargo install sqlx-cli --no-default-features --features=rustls,sqlite

Then to create and set-up the database run:

sqlx database create
sqlx migrate run

Run The Application

Start the application with:

cargo run

The app will be viewable in the browser at http://localhost:8080.

Modifying The Example Database

For simplicity, this example uses SQLx's offline mode. If you make any changes to the database schema, this must be turned off or the sqlx-data.json file regenerated using the following command:

DATABASE_URL="sqlite://$(pwd)/todo.db" cargo sqlx prepare