Skip to content

panla/fastapi_tortoise_mysql

Repository files navigation

README

A demo that use the async web frame work: FastAPI, async orm: Tortoise-ORM, the database: MySQL

  • GitHub stars GitHub forks stars gitee forks
  • GitHub version
  • MIT licensed
  • Github Repo Gitee Repo

keywords

  • python-3.9 python-asyncio
  • FastAPI pydantic tortoise-orm
  • MySQL Redis
  • MQTT Celery

environment

command

# test
make test

CODE_ENV=test pytest --rootdir ./tests -s

# run
make run

dir and file

project file

some tools

deploy and dir

build and run

# download docker and docker-compose

# create docker network: example
docker network create --driver bridge --subnet xxxxxx --gateway xxxxx xxxxxxxx

# mkdir project dir
mkdir /srv/project && cd /srv/project && mkdir conf/fastapi_tm_api conf/fastapi_tm_db conf/fastapi_tm_redis -p

# clone source code
git clone this api fastapi_tm_api

## edit config settings
# reference resources ./docs/deploy/docker-compose.yaml
touch docker-compose.yaml

# reference resources ./docs/deploy/my.cnf
touch conf/fastapi_tm_db/my.cnf

# reference resources ./conf/product.toml ./conf/test.toml
touch conf/fastapi_tm_api/product.local.toml
touch conf/fastapi_tm_api/test.local.toml

# reference resources ./docs/deploy/gunicorn_settings_example.py
touch conf/fastapi_tm_api/gunicorn_config.py

# reference resources ./docs/deploy/docker-entrypoint.sh
touch conf/fastapi_tm_api/docker-entrypoint.sh

# build and start
docker-compose up -d --build

the project dir example

.
├── api
├── conf
│   ├── fastapi_tm_api
│   │   ├── product.local.toml
│   │   ├── test.local.toml
│   │   ├── docker-entrypoint.sh
│   │   └── gunicorn_config.py
│   ├── fastapi_tm_db
│   │   └── my.cnf
│   └── fastapi_tm_redis
│       └── redis.conf
├── data
│   ├── fastapi_tm_db
│   │   └── data
│   └── fastapi_tm_redis
│       └── data
│           └── dump.rdb
├── docker-compose.yaml
└── logs
    ├── fastapi_tm_api
    │   └── x.log
    └── fastapi_tm_celery

About

a demo that use the async web_frame_work FastAPI, async orm tortoise-orm, the database MySQL

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages