# fastapi_tortoise_mysql **Repository Path**: linyaofai/fastapi_tortoise_mysql ## Basic Information - **Project Name**: fastapi_tortoise_mysql - **Description**: 对异步框架FastAPI,异步ORM Tortoise-orm,和 MySQL 数据库的综合demo - **Primary Language**: Python - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 11 - **Created**: 2021-10-31 - **Last Updated**: 2021-10-31 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # README > a demo that use the async web frame work: FastAPI, async orm: tortoise-orm, the database: MySQL - - ## tags - *asyncio* - *fastapi* - *tortoise-orm* - *MySQL* - *Redis* - *socket.io* - *websockets* ## environment - Python: 3.8 - [require packets for work](./mirrors/requirements.txt) - [require packets for dev and test](./mirrors/requirements_dev.txt) ## command ```bash # test make test CODE_ENV=test pytest --rootdir ./tests -s # run make run ``` ## dir and file ### project file - [license](./LICENSE) - [a global config file](./config.py) - [dir or file for using Cython cythonize](./build.txt) - [the program entry file](./main.py) - [Dokerfile](./Dockerfile) - [Makefile](./Makefile) - [the conf file of aerich](./aerich.ini) - [the conf file oh aerich, new](./pyproject.toml) - [the different version`s change log record for this project](./CHANGELOG.md) - [the config of pytest](./pytest.ini) ### some tools - [the script of create blank migration sql file](./tools/create_migration_template_file.py) - [the script of find target in some dirs](./tools/find.py) - [the script of insert some data into database](./tools/insert_data.py) - [the extend worker](./tools/worker.py) ## deploy and dir ### build and run ```bash # download docker and docker-compose # create docker network: example docker network create --driver bridge --subnet 172.22.0.0/16 --gateway 172.22.0.1 fastapi_net # mkdir project dir mkdir /srv/project && cd /srv/project && mkdir conf/api conf/mysql -p # clone source code git clone this api ## edit config settings # reference resources ./docs/deploy/docker-compose.yaml touch docker-compose.yaml # reference resources ./docs/deploy/my.cnf touch conf/mysql/my.cnf # reference resources ./docs/deploy/product.toml test.toml touch conf/api/conf/product.toml test.toml # reference resources ./docs/deploy/gunicorn_settings_example.py touch conf/api/gunicorn_config.py # reference resources ./docs/deploy/docker-entrypoint.sh touch conf/api/docker-entrypoint.sh # build and start docker-compose up -d --build ``` ### the project dir example ```text project ├── api │   ├── ... conf │ ├── api │ │   ├── conf │ │   │   ├── product.toml │ │   │   └── test.toml │ │   ├── docker-entrypoint.sh │ │   ├── gunicorn_config.py │ │   └── run.sh │ └── mysql │ ├── my.cnf │ └── sources.list ├── data │   ├── mysql │   │   └── data │   └── redis │   └── data │   └── dump.rdb ├── docker-compose.yml ├── logs │   └── api ```