https://github.com/amozebus/fastapi-beyond-crud-2
Template for API that uses PostgreSQL-database / Шаблон API, использующего базу данных PostgreSQL
https://github.com/amozebus/fastapi-beyond-crud-2
alembic fastapi fastapi-template postgresql python sqlmodel
Last synced: 7 months ago
JSON representation
Template for API that uses PostgreSQL-database / Шаблон API, использующего базу данных PostgreSQL
- Host: GitHub
- URL: https://github.com/amozebus/fastapi-beyond-crud-2
- Owner: amozebus
- License: mit
- Created: 2025-02-02T23:37:44.000Z (8 months ago)
- Default Branch: master
- Last Pushed: 2025-02-05T20:54:33.000Z (8 months ago)
- Last Synced: 2025-02-19T14:16:53.200Z (8 months ago)
- Topics: alembic, fastapi, fastapi-template, postgresql, python, sqlmodel
- Language: Python
- Homepage:
- Size: 49.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FastAPI Beyond CRUD 2 (with PostgreSQL)
Template for API that uses [PostgreSQL](https://postgresql.org)-database. Written in [Python](https://python.org) with [FastAPI](https://fastapi.tiangolo.com), [asyncpg](https://github.com/MagicStack/asyncpg) as database client, [SQLModel](https://sqlmodel.tiangolo.com) as ORM
Included [Alembic](https://alembic.sqlalchemy.org) for database migrations
Users' passwords hashing with [BCrypt](https://en.wikipedia.org/wiki/Bcrypt) and users authorization with access [JWTs](https://jwt.io)
## How to run
1. Rename `.env.example` to `.env` and fill fields
* Fields:
```
DATABASE_URL (str): PostgreSQL-database URLJWT_SECRET (str): secret for JWTs signature
ACCESS_TOKEN_EXPIRE (int): access JWTs expire time in seconds
```2. Install dependencies:
```sh
pip install -r requirements.txt
```3. Run database migrations:
```sh
alembic upgrade head
```3. Run app:
```sh
python src/main.py
```### Docker
2. Build Docker image:
```sh
docker build . --tag api
```3. Run Docker image:
```sh
docker run -d api
```4. Run database migrations:
```sh
docker exec {container id} alembic upgrade head
```