NOTE: All database configuration names can be overridden by environment variables see settings.py file
Then run:
docker-compose -f docker-compose.yml up
If you have already postgres installed in your host machine then:
Create database fastapidb
create database fastapidb;
Run app with docker:
docker run -d --rm --network=host meschac38000/fast-api:latest
The ap running on http://127.0.0.1:8000/
- Postgresql
- python
Note that, you can create a virtual environment if you don't want to install requirements in your host machine
For that run the following command depending on your system:
python -m venv {venv-name}
activate this virtual environment
Linux or Mac
source {venv-name}/bin/activate
Windows
./{venv-name}/Scripts/activate
Upgrade pip
pip install --upgrade pip
install application requirements
pip install -r requirements/common.txt
install dev requirements (useful to run tests)
pip install -r requirements/dev.txt
Connect to your postgres BD using psql
psql -U postgres -p 5432 -h localhost
Then create DB fastapidb
CREATE DATABASE fastapidb;
Then edit correctly TORTOISE_ORM
variable in the settings.py file.
We are using Aerich as database migrations tool. Init database by running the following aerich command:
aerich init-db
python main.py
The app running on http://127.0.0.1:8000/
To load some fake data, go to http://127.0.0.1:8000/data which will load fake data.
from root folder(Test-FastAPI/)
run:
pytest
Made by: