From 0bb3576e9060bf75c16ab334d32e4a9955513546 Mon Sep 17 00:00:00 2001 From: grillazz Date: Sat, 8 Mar 2025 20:26:13 +0100 Subject: [PATCH 1/2] bump postgresql version --- db/Dockerfile | 2 +- pyproject.old | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 pyproject.old diff --git a/db/Dockerfile b/db/Dockerfile index 697c3de..bfd3a80 100644 --- a/db/Dockerfile +++ b/db/Dockerfile @@ -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 diff --git a/pyproject.old b/pyproject.old new file mode 100644 index 0000000..1edb243 --- /dev/null +++ b/pyproject.old @@ -0,0 +1,90 @@ +[tool.poetry] +name = "fastapi-sqlalchemy-asyncpg" +version = "0.0.17" +description = "" +authors = ["Jakub Miazek "] +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" \ No newline at end of file From ce40b7a6d99508453fdd4b1a3812cb1ebf907fc8 Mon Sep 17 00:00:00 2001 From: grillazz Date: Sat, 8 Mar 2025 20:52:45 +0100 Subject: [PATCH 2/2] update README.md --- README.md | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index fb01a43..8533f45 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,11 @@
  • How to feed database
  • Rainbow logs with rich
  • Setup user auth
  • -
  • Local development with poetry
  • +
  • Setup local development with uv
  • Import xlsx files with polars and calamine
  • Schedule jobs
  • Email Configuration
  • +
  • UV knowledge and inspirations
  • Acknowledgments
  • @@ -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)

    (back to top)

    ### 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 - -```shell -pyenv install 3.13 && pyenv local 3.13 -``` +### Setup local env with uv ```shell -poetry install --with dev +uv sync +source .venv/bin/activate ``` -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. +

    (back to top)

    + +### 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! 🐍📦 + +

    (back to top)

    ## 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:

    (back to top)

    @@ -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/