https://github.com/haitwang-cloud/fastapi-alembic-sqlmodel-sample
Make an out-of-the-box backend based on FastAPI
https://github.com/haitwang-cloud/fastapi-alembic-sqlmodel-sample
Last synced: 7 months ago
JSON representation
Make an out-of-the-box backend based on FastAPI
- Host: GitHub
- URL: https://github.com/haitwang-cloud/fastapi-alembic-sqlmodel-sample
- Owner: haitwang-cloud
- License: apache-2.0
- Created: 2021-12-20T10:32:29.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-04-12T03:25:52.000Z (over 2 years ago)
- Last Synced: 2024-04-12T11:16:26.538Z (over 2 years ago)
- Language: Python
- Size: 160 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fastapi-app-sample
Make an out-of-the-box backend based on FastAPI
```bash
FastAPI + MySQL + Requests+ alembic + SQLmodel + aiohttp + sqlalchemy
```
### Project screen shoot

### Project API doc
```bash
http://0.0.0.0:8000
```
### Tree view
```bash
├── Dockerfile
├── LICENSE
├── README.md
├── alembic
│ ├── README
│ ├── env.py
│ ├── script.py.mako
│ └── versions
├── alembic.ini
├── app
│ ├── client
│ │ ├── cats_client.py
│ │ ├── hitokoto_client.py
│ │ └── http.py
│ ├── db
│ │ ├── crud.py
│ │ ├── database.py
│ │ └── init.py
│ ├── models
│ │ ├── __init__.py
│ │ └── models.py
│ ├── router
│ │ ├── animal.py
│ │ ├── api.py
│ │ ├── db.py
│ │ └── tools.py
│ ├── test
│ │ ├── benchmarktest
│ │ │ └── locustfile.py
│ │ └── unnitest
│ │ └── test_animal.py
│ └── utils
│ ├── log_init.py
│ └── logging_config.json
├── config.ini
├── docker
│ ├── build.sh
│ └── run.sh
├── handler.py
├── main.py
├── migration
├── pip.conf
├── requirements.txt
└── sample.gif
```
## Database
Offical
docs: [https://alembic.sqlalchemy.org/en/latest/tutorial.html](https://alembic.sqlalchemy.org/en/latest/tutorial.html)
### Init
```bash
alembic init alembic
```
### Editing the alembic.ini File
```bash
Please edit configuration/connection/logging settings in './fastapi-app-sample/alembic.ini' before proceeding
```
### Create a Migration Script
```bash
alembic revision -m "create account table"
Generating /path/to/yourproject/alembic/versions/1975ea83b712_create_accoun
t_table.py...done
```
## Docker
### how to build images
```bash
sh docker/build.sh
```
## how to run
```bash
sh docker/run.sh
```
## Test
### unnitest
[pytest](https://docs.pytest.org/en/6.2.x/)
### benchmarkest
[locust](http://docs.locust.io/en/stable/configuration.html)
## References
- [https://fastapi.tiangolo.com/tutorial/](https://fastapi.tiangolo.com/tutorial/)
- [https://sqlmodel.tiangolo.com/](https://sqlmodel.tiangolo.com/)
- [https://docs.aiohttp.org/en/stable/](https://docs.aiohttp.org/en/stable/)
- [https://github.com/Delgan/loguru](https://github.com/Delgan/loguru)
- [https://docs.python-requests.org/en/master/](https://docs.python-requests.org/en/master/)
- [https://docs.sqlalchemy.org/en/14/](https://docs.sqlalchemy.org/en/14/)
- [https://github.com/alembic/alembic](https://github.com/alembic/alembic)
## Commit History
[](https://the-commit-history.vercel.app/#haitwang-cloud/fastapi-alembic-sqlmodel-sample&Timeline)