From 7b79b4a0bf3ec5acc769761d543f8b843b2705e5 Mon Sep 17 00:00:00 2001 From: Cody Fincher Date: Sat, 11 May 2024 21:20:09 +0000 Subject: [PATCH 1/4] chore: fix type hint for 3.8 support --- advanced_alchemy/service/pagination.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/advanced_alchemy/service/pagination.py b/advanced_alchemy/service/pagination.py index 84075376..a4b3514e 100644 --- a/advanced_alchemy/service/pagination.py +++ b/advanced_alchemy/service/pagination.py @@ -1,7 +1,7 @@ from __future__ import annotations from dataclasses import dataclass -from typing import Generic, TypeVar +from typing import Generic, List, TypeVar from uuid import UUID T = TypeVar("T") @@ -16,7 +16,7 @@ class OffsetPagination(Generic[T]): __slots__ = ("items", "limit", "offset", "total") - items: list[T] + items: List[T] # noqa: UP006 """List of data being sent as part of the response.""" limit: int """Maximal number of items to send.""" From d80475b4d31b4c8d72dbe52bec9bc67e626a0841 Mon Sep 17 00:00:00 2001 From: Cody Fincher Date: Sat, 11 May 2024 21:26:21 +0000 Subject: [PATCH 2/4] docs: add github URL to docs --- docs/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/conf.py b/docs/conf.py index 44d60f52..e3cadd00 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -140,6 +140,7 @@ html_theme_options = { "logo_target": "/", "github_repo_name": "advanced-alchemy", + "github_url": "https://github.com/litestar-org/advanced-alchemy", "navigation_with_keys": True, "nav_links": [ # TODO(provinzkraut): I need a guide on extra_navbar_items and its magic :P {"title": "Home", "url": "index"}, From 34ce72e23cbf75b51cf124d830cf68a9b4d49a95 Mon Sep 17 00:00:00 2001 From: Cody Fincher Date: Sat, 11 May 2024 22:40:02 +0000 Subject: [PATCH 3/4] chore: clean up readme verbiage --- README.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 41a8bdd7..7c91f2e3 100644 --- a/README.md +++ b/README.md @@ -28,15 +28,14 @@ Check out the [project documentation][project-docs] 📚 for more information. ## About A carefully crafted, thoroughly tested, optimized companion library for SQLAlchemy, -offering features such as: +offering: - Sync and async repositories, featuring common CRUD and highly optimized bulk operations -- Integration with major web frameworks including Litestar, Starlette, FastAPI, Sanic. +- Integration with major web frameworks including Litestar, Starlette, FastAPI, Sanic - Custom-built alembic configuration and CLI with optional framework integration - Utility base classes with audit columns, primary keys and utility functions -- Optimized JSON types including a custom JSON type for Oracle. +- Optimized JSON types including a custom JSON type for Oracle - Integrated support for UUID6 and UUID7 using [`uuid-utils`](https://github.com/aminalaee/uuid-utils) (install with the `uuid` extra) - - Pre-configured base classes with audit columns UUID or Big Integer primary keys and a [sentinel column](https://docs.sqlalchemy.org/en/20/core/connections.html#configuring-sentinel-columns). - Synchronous and asynchronous repositories featuring: @@ -46,7 +45,6 @@ offering features such as: for improved query building performance - Integrated counts, pagination, sorting, filtering with `LIKE`, `IN`, and dates before and/or after. - Tested support for multiple database backends including: - - SQLite via [aiosqlite](https://aiosqlite.omnilib.dev/en/stable/) or [sqlite](https://docs.python.org/3/library/sqlite3.html) - Postgres via [asyncpg](https://magicstack.github.io/asyncpg/current/) or [psycopg3 (async or sync)](https://www.psycopg.org/psycopg3/) - MySQL via [asyncmy](https://github.com/long2ice/asyncmy) @@ -55,6 +53,7 @@ offering features such as: - DuckDB via [duckdb_engine](https://github.com/Mause/duckdb_engine) - Microsoft SQL Server via [pyodbc](https://github.com/mkleehammer/pyodbc) or [aioodbc](https://github.com/aio-libs/aioodbc) - CockroachDB via [sqlalchemy-cockroachdb (async or sync)](https://github.com/cockroachdb/sqlalchemy-cockroachdb) +- ...and much more ## Usage @@ -129,6 +128,7 @@ with session_factory() as db_session: remaining_count = repo.count() print(f"Found {remaining_count} remaining records after delete.") ``` + For a full standalone example, see the sample [here][standalone-example] @@ -201,6 +201,7 @@ with session_factory() as db_session: remaining_count = service.count() print(f"Found {remaining_count} remaining records after delete.") ``` + ### Web Frameworks @@ -230,6 +231,7 @@ alchemy = SQLAlchemyPlugin( ) app = Litestar(plugins=[alchemy]) ``` + For a full Litestar example, check [here][litestar-example] @@ -250,6 +252,7 @@ alchemy = StarletteAdvancedAlchemy( config=SQLAlchemyAsyncConfig(connection_string="sqlite+aiosqlite:///test.sqlite"), app=app, ) ``` + For a full FastAPI example, see [here][fastapi-example] @@ -270,6 +273,7 @@ alchemy = StarletteAdvancedAlchemy( config=SQLAlchemyAsyncConfig(connection_string="sqlite+aiosqlite:///test.sqlite"), app=app, ) ``` + #### Sanic @@ -290,6 +294,7 @@ alchemy = SanicAdvancedAlchemy( ) Extend.register(alchemy) ``` + ## Contributing From d955fc70dc0391446e3d8024bfadac9daefa7cb5 Mon Sep 17 00:00:00 2001 From: Cody Fincher Date: Sat, 11 May 2024 22:43:32 +0000 Subject: [PATCH 4/4] chore: updated readme addresses --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7c91f2e3..80d4de38 100644 --- a/README.md +++ b/README.md @@ -107,10 +107,10 @@ with session_factory() as db_session: repo = UserRepository(session=db_session) # 1) Create multiple users with `add_many` bulk_users = [ - {"email": 'cody@advanced-alchemy.dev', 'name': 'Cody'}, - {"email": 'janek@advanced-alchemy.dev', 'name': 'Janek'}, - {"email": 'peter@advanced-alchemy.dev', 'name': 'Peter'}, - {"email": 'jacob@advanced-alchemy.dev', 'name': 'Jacob'} + {"email": 'cody@litestar.dev', 'name': 'Cody'}, + {"email": 'janek@litestar.dev', 'name': 'Janek'}, + {"email": 'peter@litestar.dev', 'name': 'Peter'}, + {"email": 'jacob@litestar.dev', 'name': 'Jacob'} ] objs = repo.add_many([User(**raw_user) for raw_user in bulk_users]) db_session.commit() @@ -181,10 +181,10 @@ with session_factory() as db_session: service = UserService(session=db_session) # 1) Create multiple users with `add_many` objs = service.create_many([ - {"email": 'cody@advanced-alchemy.dev', 'name': 'Cody'}, - {"email": 'janek@advanced-alchemy.dev', 'name': 'Janek'}, - {"email": 'peter@advanced-alchemy.dev', 'name': 'Peter'}, - {"email": 'jacob@advanced-alchemy.dev', 'name': 'Jacob'} + {"email": 'cody@litestar.dev', 'name': 'Cody'}, + {"email": 'janek@litestar.dev', 'name': 'Janek'}, + {"email": 'peter@litestar.dev', 'name': 'Peter'}, + {"email": 'jacob@litestar.dev', 'name': 'Jacob'} ]) print(objs) print(f"Created {len(objs)} new objects.")