mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-08-26 16:40:40 +03:00
Merge pull request #199 from grillazz/195-switch-project-to-uv
195 switch project to uv
This commit is contained in:
commit
41a8688aae
41
README.md
41
README.md
@ -26,10 +26,11 @@
|
||||
<li><a href="#how-to-feed-database">How to feed database</a></li>
|
||||
<li><a href="#rainbow-logs-with-rich">Rainbow logs with rich</a></li>
|
||||
<li><a href="#setup-user-auth">Setup user auth</a></li>
|
||||
<li><a href="#local-development-with-poetry">Local development with poetry</a></li>
|
||||
<li><a href="#setup-local-env-with-uv">Setup local development with uv</a></li>
|
||||
<li><a href="#import-xlsx-files-with-polars-and-calamine">Import xlsx files with polars and calamine</a></li>
|
||||
<li><a href="#worker-aware-async-scheduler">Schedule jobs</a></li>
|
||||
<li><a href="#smtp-setup">Email Configuration</a></li>
|
||||
<li><a href="#uv-knowledge-and-inspirations">UV knowledge and inspirations</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#acknowledgments">Acknowledgments</a></li>
|
||||
@ -44,7 +45,7 @@
|
||||
This example demonstrates the seamless integration of [FastAPI](https://fastapi.tiangolo.com/), a modern, high-performance web framework,
|
||||
with [Pydantic 2.0](https://github.com/pydantic/pydantic), a robust and powerful data validation library.
|
||||
The integration is further enhanced by the use of [SQLAlchemy ORM](https://www.sqlalchemy.org/), a popular and feature-rich Object-Relational Mapping tool,
|
||||
and [PostgreSQL16](https://www.postgresql.org/about/news/postgresql-16-released-2715/) relational database.
|
||||
and [PostgreSQL17](https://www.postgresql.org/docs/17/release.html) relational database.
|
||||
|
||||
The entire stack is connected using the [asyncpg](https://github.com/MagicStack/asyncpg) Database Client Library,
|
||||
which provides a robust and efficient way to interact with PostgreSQL databases in Python,
|
||||
@ -56,7 +57,7 @@ allowing for the rapid development of APIs with Python 3.8+.
|
||||
|
||||
FastAPI has received significant recognition in the industry, including a review on thoughtworks Technology Radar in April 2021,
|
||||
where it was classified as a Trial technology, with comments praising its performance, ease of use,
|
||||
and features such as API documentation using OpenAPI. Additionally, FastAPI was recognized in the Python Developers Survey 2022 Results,
|
||||
and features such as API documentation using OpenAPI. Additionally, FastAPI was recognized in the Python Developers Survey 2023 Results,
|
||||
conducted by the Python Software Foundation and JetBrains, where it was reported that 1 in 4 Python developers use FastAPI,
|
||||
with a 4 percentage point increase from the previous year.
|
||||
|
||||
@ -86,7 +87,8 @@ To build , run and test and more ... use magic of make help to play with this pr
|
||||
4. make docker-feed-database
|
||||
```
|
||||
|
||||
|
||||
### Adjust make with just
|
||||
[//]: # (TODO: switch form make to just)
|
||||
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
||||
|
||||
### How to feed database
|
||||
@ -126,15 +128,11 @@ he following steps were taken to integrate [rich](https://github.com/Textualize/
|
||||
|
||||
Setup user authentication with JWT and Redis as token storage.
|
||||
|
||||
### Local development with poetry
|
||||
|
||||
### Setup local env with uv
|
||||
```shell
|
||||
pyenv install 3.13 && pyenv local 3.13
|
||||
uv sync
|
||||
source .venv/bin/activate
|
||||
```
|
||||
```shell
|
||||
poetry install --with dev
|
||||
```
|
||||
Hope you enjoy it.
|
||||
|
||||
### Import xlsx files with polars and calamine
|
||||
Power of Polars Library in data manipulation and analysis.
|
||||
@ -165,6 +163,16 @@ It is implemented as a singleton to ensure that only one SMTP connection is main
|
||||
throughout the application lifecycle, optimizing resource usage.
|
||||
|
||||
|
||||
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
||||
|
||||
### UV knowledge and inspirations
|
||||
- https://docs.astral.sh/uv/
|
||||
- https://hynek.me/articles/docker-uv/
|
||||
- https://thedataquarry.com/posts/towards-a-unified-python-toolchain/
|
||||
- https://www.youtube.com/watch?v=ifj-izwXKRA&t=760s > UV and Ruff: Next-gen Python Tooling
|
||||
- https://www.youtube.com/watch?v=8UuW8o4bHbw&t=1s > uv IS the Future of Python Packaging! 🐍📦
|
||||
|
||||
|
||||
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
||||
|
||||
## Acknowledgments
|
||||
@ -206,6 +214,7 @@ I've included a few of my favorites to kick things off!
|
||||
- **[OCT 16 2024]** apscheduler added to project :clock1:
|
||||
- **[DEC 16 2024]** bump project to Python 3.13 :fast_forward:
|
||||
- **[JAN 28 2025]** add SMTP setup :email:
|
||||
- **[MAR 8 2025]** switch from poetry to uv :fast_forward:
|
||||
|
||||
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
||||
|
||||
@ -225,19 +234,19 @@ I've included a few of my favorites to kick things off!
|
||||
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
|
||||
[linkedin-url]: https://www.linkedin.com/in/python-has-powers/
|
||||
|
||||
[fastapi.tiangolo.com]: https://img.shields.io/badge/FastAPI-0.115.6-009485?style=for-the-badge&logo=fastapi&logoColor=white
|
||||
[fastapi.tiangolo.com]: https://img.shields.io/badge/FastAPI-0.115.11-009485?style=for-the-badge&logo=fastapi&logoColor=white
|
||||
[fastapi-url]: https://fastapi.tiangolo.com/
|
||||
[pydantic.com]: https://img.shields.io/badge/Pydantic-2.10.3-e92063?style=for-the-badge&logo=pydantic&logoColor=white
|
||||
[pydantic.com]: https://img.shields.io/badge/Pydantic-2.10.6-e92063?style=for-the-badge&logo=pydantic&logoColor=white
|
||||
[pydantic-url]: https://docs.pydantic.dev/latest/
|
||||
[sqlalchemy.org]: https://img.shields.io/badge/SQLAlchemy-2.0.36-bb0000?color=bb0000&style=for-the-badge
|
||||
[sqlalchemy.org]: https://img.shields.io/badge/SQLAlchemy-2.0.38-bb0000?color=bb0000&style=for-the-badge
|
||||
[sqlalchemy-url]: https://docs.sqlalchemy.org/en/20/
|
||||
[uvicorn.org]: https://img.shields.io/badge/Uvicorn-0.34.0-2094f3?style=for-the-badge&logo=uvicorn&logoColor=white
|
||||
[uvicorn-url]: https://www.uvicorn.org/
|
||||
[asyncpg.github.io]: https://img.shields.io/badge/asyncpg-0.30.0-2e6fce?style=for-the-badge&logo=postgresql&logoColor=white
|
||||
[asyncpg-url]: https://magicstack.github.io/asyncpg/current/
|
||||
[pytest.org]: https://img.shields.io/badge/pytest-8.3.4-fff?style=for-the-badge&logo=pytest&logoColor=white
|
||||
[pytest.org]: https://img.shields.io/badge/pytest-8.3.5-fff?style=for-the-badge&logo=pytest&logoColor=white
|
||||
[pytest-url]: https://docs.pytest.org/en/6.2.x/
|
||||
[alembic.sqlalchemy.org]: https://img.shields.io/badge/alembic-1.14.0-6BA81E?style=for-the-badge&logo=alembic&logoColor=white
|
||||
[alembic.sqlalchemy.org]: https://img.shields.io/badge/alembic-1.15.1-6BA81E?style=for-the-badge&logo=alembic&logoColor=white
|
||||
[alembic-url]: https://alembic.sqlalchemy.org/en/latest/
|
||||
[rich.readthedocs.io]: https://img.shields.io/badge/rich-13.9.4-009485?style=for-the-badge&logo=rich&logoColor=white
|
||||
[rich-url]: https://rich.readthedocs.io/en/latest/
|
||||
|
@ -1,5 +1,5 @@
|
||||
# pull official base image
|
||||
FROM postgres:16-alpine
|
||||
FROM postgres:17.4-alpine
|
||||
|
||||
# run create.sql on init
|
||||
ADD create.sql /docker-entrypoint-initdb.d
|
||||
|
90
pyproject.old
Normal file
90
pyproject.old
Normal file
@ -0,0 +1,90 @@
|
||||
[tool.poetry]
|
||||
name = "fastapi-sqlalchemy-asyncpg"
|
||||
version = "0.0.17"
|
||||
description = ""
|
||||
authors = ["Jakub Miazek <the@grillazz.com>"]
|
||||
packages = []
|
||||
license = "MIT"
|
||||
package-mode = false
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.13"
|
||||
fastapi = {version = "^0.115.6", extras = ["all"]}
|
||||
pydantic = {version = "^2.10.3", extras = ["email"]}
|
||||
pydantic-settings = "^2.7.0"
|
||||
sqlalchemy = "^2.0.36"
|
||||
uvicorn = { version = "^0.34.0", extras = ["standard"]}
|
||||
asyncpg = "^0.30.0"
|
||||
alembic = "^1.14.0"
|
||||
httpx = "^0.28.1"
|
||||
pytest = "^8.3.4"
|
||||
pytest-cov = "^6.0.0"
|
||||
uvloop = "^0.21.0"
|
||||
httptools = "^0.6.4"
|
||||
rich = "^13.9.4"
|
||||
pyjwt = {version = "^2.10.1", extras = ["cryptography"]}
|
||||
redis = "^5.2.1"
|
||||
bcrypt = "^4.2.1"
|
||||
polars = "^1.17.1"
|
||||
python-multipart = "^0.0.20"
|
||||
fastexcel = "^0.12.0"
|
||||
fastapi-cache2 = "^0.2.1"
|
||||
inline-snapshot = "^0.17.0"
|
||||
dirty-equals = "^0.8.0"
|
||||
polyfactory = "^2.18.1"
|
||||
granian = "^1.7.0"
|
||||
apscheduler = {version = "^4.0.0a5", extras = ["redis,sqlalchemy"]}
|
||||
pendulum = {git = "https://github.com/sdispater/pendulum.git", rev="develop"}
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
devtools = { extras = ["pygments"], version = "^0.12.2" }
|
||||
safety = "*"
|
||||
pyupgrade = "*"
|
||||
ipython = "^8.26.0"
|
||||
ruff = "^0.6.1"
|
||||
sqlacodegen = "^3.0.0rc5"
|
||||
tryceratops = "^2.3.3"
|
||||
locust = "^2.31.3"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
||||
[tool.ruff]
|
||||
line-length = 120
|
||||
indent-width = 4
|
||||
|
||||
lint.select = ["E", "F", "UP", "N", "C", "B"]
|
||||
lint.ignore = ["E501"]
|
||||
|
||||
# Exclude a variety of commonly ignored directories.
|
||||
exclude = ["alembic",]
|
||||
# Assume Python 3.13
|
||||
target-version = "py313"
|
||||
|
||||
[tool.ruff.lint.flake8-quotes]
|
||||
docstring-quotes = "double"
|
||||
|
||||
[tool.ruff.lint.flake8-bugbear]
|
||||
extend-immutable-calls = ["fastapi.Depends",]
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
addopts = "-v --doctest-modules --doctest-glob=*.md --ignore=alembic"
|
||||
asyncio_mode = "strict"
|
||||
env_files = [".env"]
|
||||
|
||||
[tool.tryceratops]
|
||||
exclude = ["alembic",]
|
||||
|
||||
[tool.ruff.format]
|
||||
# Like Black, use double quotes for strings.
|
||||
quote-style = "double"
|
||||
|
||||
# Like Black, indent with spaces, rather than tabs.
|
||||
indent-style = "space"
|
||||
|
||||
# Like Black, respect magic trailing commas.
|
||||
skip-magic-trailing-comma = false
|
||||
|
||||
# Like Black, automatically detect the appropriate line ending.
|
||||
line-ending = "auto"
|
Loading…
x
Reference in New Issue
Block a user