1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-24 16:32:59 +01:00
actix-web/examples/diesel/README.md

43 lines
1015 B
Markdown
Raw Normal View History

2017-12-30 12:21:34 +01:00
# diesel
2017-12-19 01:25:26 +01:00
Diesel's `Getting Started` guide using SQLite for Actix web
## Usage
2017-12-31 08:12:26 +01:00
### init database sqlite
2017-12-19 01:25:26 +01:00
2017-12-30 12:21:34 +01:00
```bash
2017-12-19 01:25:26 +01:00
cargo install diesel_cli --no-default-features --features sqlite
2017-12-31 08:12:26 +01:00
cd actix-web/examples/diesel
echo "DATABASE_URL=file:test.db" > .env
diesel migration run
2017-12-19 01:25:26 +01:00
```
2017-12-31 08:12:26 +01:00
### server
2017-12-30 12:21:34 +01:00
```bash
2017-12-31 08:12:26 +01:00
# if ubuntu : sudo apt-get install libsqlite3-dev
# if fedora : sudo dnf install libsqlite3x-devel
cd actix-web/examples/diesel
cargo run (or ``cargo watch -x run``)
# Started http server: 127.0.0.1:8080
```
### web client
[http://127.0.0.1:8080/NAME](http://127.0.0.1:8080/NAME)
### sqlite client
```bash
# if ubuntu : sudo apt-get install sqlite3
# if fedora : sudo dnf install sqlite3x
sqlite3 test.db
sqlite> .tables
sqlite> select * from users;
2017-12-19 01:25:26 +01:00
```
2017-12-30 12:21:34 +01:00
2017-12-31 08:12:26 +01:00
2017-12-30 12:21:34 +01:00
## Postgresql
You will also find another complete example of diesel+postgresql on [https://github.com/TechEmpower/FrameworkBenchmarks/tree/master/frameworks/Rust/actix](https://github.com/TechEmpower/FrameworkBenchmarks/tree/master/frameworks/Rust/actix)