2022-02-06 09:13:24 +01:00
|
|
|
Getting started using databases with Actix Web, asynchronously.
|
2018-05-26 23:05:12 +02:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
### init database sqlite
|
|
|
|
|
|
|
|
From the root directory of this project:
|
2022-03-06 01:43:10 +01:00
|
|
|
|
2022-02-18 04:36:04 +01:00
|
|
|
```sh
|
2018-05-26 23:05:12 +02:00
|
|
|
bash db/setup_db.sh
|
|
|
|
```
|
|
|
|
|
|
|
|
This creates a sqlite database, weather.db, in the root.
|
|
|
|
|
|
|
|
### server
|
|
|
|
|
2022-02-18 04:36:04 +01:00
|
|
|
```sh
|
2018-05-26 23:05:12 +02:00
|
|
|
# if ubuntu : sudo apt-get install libsqlite3-dev
|
|
|
|
# if fedora : sudo dnf install libsqlite3x-devel
|
2022-02-18 04:13:49 +01:00
|
|
|
cargo run
|
2018-05-26 23:05:12 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
### web client
|
|
|
|
|
|
|
|
[http://127.0.0.1:8080/asyncio_weather](http://127.0.0.1:8080/asyncio_weather)
|
|
|
|
|
|
|
|
[http://127.0.0.1:8080/parallel_weather](http://127.0.0.1:8080/parallel_weather)
|
|
|
|
|
|
|
|
### sqlite client
|
|
|
|
|
2022-02-18 04:36:04 +01:00
|
|
|
```sh
|
2018-05-26 23:05:12 +02:00
|
|
|
# if ubuntu : sudo apt-get install sqlite3
|
|
|
|
# if fedora : sudo dnf install sqlite3x
|
|
|
|
sqlite3 weather.db
|
|
|
|
sqlite> .tables
|
|
|
|
sqlite> select * from nyc_weather;
|
|
|
|
```
|
|
|
|
|
2020-01-12 14:04:02 +01:00
|
|
|
## Dependencies
|
|
|
|
|
|
|
|
On Ubuntu 19.10:
|
|
|
|
|
|
|
|
```
|
|
|
|
sudo apt install libsqlite3-dev
|
|
|
|
```
|