2020-04-23 10:03:04 +02:00
|
|
|
# actix-sqlx-todo
|
|
|
|
|
2021-03-03 15:37:17 +01:00
|
|
|
Example Todo application using Actix-web and [SQLx](https://github.com/launchbadge/sqlx) with sqlite
|
2020-04-23 10:03:04 +02:00
|
|
|
|
|
|
|
# Usage
|
|
|
|
|
|
|
|
## Prerequisites
|
|
|
|
|
|
|
|
* Rust
|
2021-03-03 15:37:17 +01:00
|
|
|
* SQLite
|
2020-04-23 10:03:04 +02:00
|
|
|
|
|
|
|
## Change into the project sub-directory
|
|
|
|
|
2021-10-07 04:00:13 +02:00
|
|
|
All instructions assume you have changed into this directory:
|
2020-04-23 10:03:04 +02:00
|
|
|
|
|
|
|
```bash
|
2021-10-07 04:00:13 +02:00
|
|
|
$ cd database_interactions/sqlx_todo
|
2020-04-23 10:03:04 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
## Set up the database
|
|
|
|
|
2022-01-29 17:25:46 +01:00
|
|
|
* Create new database:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
./setup_db.sh
|
|
|
|
```
|
|
|
|
|
2021-10-07 04:00:13 +02:00
|
|
|
* Copy `.env.example` into `.env` and adjust `DATABASE_URL` to match your SQLite address, if needed
|
|
|
|
|
|
|
|
```sh
|
|
|
|
cat schema.sql | sqlite3 test.db
|
|
|
|
cp .env.example .env
|
|
|
|
```
|
2020-04-23 10:03:04 +02:00
|
|
|
|
|
|
|
## Run the application
|
|
|
|
|
|
|
|
To run the application execute:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
cargo run
|
|
|
|
```
|
|
|
|
|
2022-01-29 17:25:46 +01:00
|
|
|
By default the application will be available on `http://localhost:8080`. If you wish to change address or port you can do it inside the `.env` file
|