{"by":"Kumzy","descendants":12,"id":43771816,"kids":[43774173,43774775,43773842,43774369,43774712,43773906,43775512,43775836,43774629],"score":38,"text":"Hello HN!<p>Advanced Alchemy is an optimized companion library for SQLAlchemy, designed to supercharge your database models with powerful tooling for migrations, asynchronous support, lifecycle hook and more.<p>You can find the repository and documentation here:<p><pre><code>    - GitHub Repository: https:&#x2F;&#x2F;github.com&#x2F;litestar-org&#x2F;advanced-alchemy\n    - Official Documentation : https:&#x2F;&#x2F;docs.advanced-alchemy.litestar.dev&#x2F;latest&#x2F;\n</code></pre>\nAdvanced-Alchemy extends SQLAlchemy with productivity-enhancing features, while keeping full compatibility with the ecosystem you already know.<p>At its core, Advanced-Alchemy offers:<p>- Sync and async repositories, featuring common CRUD and highly optimized bulk operations<p>- Integration with major web frameworks including Litestar, Starlette, FastAPI, Sanic<p>- Custom-built alembic configuration and CLI with optional framework integration<p>- Utility base classes with audit columns, primary keys and utility functions<p>- Built in File Object data type for storing objects:<p><pre><code>    - Unified interface for various storage backends fsspec and obstore\n    - Optional lifecycle event hooks integrated with SQLAlchemy&#x27;s event system to automatically save and delete files as records are inserted, updated, or deleted.\n</code></pre>\n- Optimized JSON types including a custom JSON type for Oracle<p>- Integrated support for UUID6 and UUID7 using uuid-utils<p>- Integrated support for Nano ID using fastnanoid<p>- Pre-configured base classes with audit columns UUID or Big Integer primary keys and a sentinel column.<p>- Synchronous and asynchronous repositories featuring:<p><pre><code>    - Common CRUD operations for SQLAlchemy models\n    - Bulk inserts, updates, upserts, and deletes with dialect-specific enhancements\n    - Integrated counts, pagination, sorting, filtering with LIKE, IN, and dates before and&#x2F;or after.\n</code></pre>\n- Tested support for multiple database backends including:<p><pre><code>    - SQLite via aiosqlite or sqlite\n    - Postgres via asyncpg or psycopg3 (async or sync)\n    - MySQL via asyncmy\n    - Oracle via oracledb (async or sync) (tested on 18c and 23c)\n    - Google Spanner via spanner-sqlalchemy\n    - DuckDB via duckdb_engine\n    - Microsoft SQL Server via pyodbc or aioodbc\n    - CockroachDB via sqlalchemy-cockroachdb (async or sync)\n</code></pre>\nThe framework is designed to be lightweight yet powerful, with a clean API that makes it easy to integrate into existing projects.<p>You can find a full example using FastAPI there: <a href=\"https:&#x2F;&#x2F;docs.advanced-alchemy.litestar.dev&#x2F;latest&#x2F;usage&#x2F;frameworks&#x2F;fastapi.html\" rel=\"nofollow\">https:&#x2F;&#x2F;docs.advanced-alchemy.litestar.dev&#x2F;latest&#x2F;usage&#x2F;fram...</a><p>There are custom datatypes, a service and repository (including optimized bulk operations), and native integration with Flask, FastAPI, Starlette, Litestar and Sanic.<p>Feedback and enhancements are always welcomed! We have an active discord community, so if you don&#x27;t get a response on an issue or would like to chat directly with the dev team, please reach out.<p>The library: <a href=\"https:&#x2F;&#x2F;github.com&#x2F;litestar-org&#x2F;advanced-alchemy\">https:&#x2F;&#x2F;github.com&#x2F;litestar-org&#x2F;advanced-alchemy</a>","time":1745414268,"title":"Show HN: Advanced-Alchemy – A framework agnostic library for SQLAlchemy","type":"story","url":"https://github.com/litestar-org/advanced-alchemy"}