Release v1.1.0
January 12, 2026 ยท View on GitHub
๐ What's New
This major release introduces multi-ORM support, allowing you to choose between SQLAlchemy, Tortoise ORM, and Peewee. The library now uses an adapter pattern to provide a unified interface for different ORM implementations, making it more flexible and extensible.
โจ New Features
- Multi-ORM Support: Choose your preferred ORM - SQLAlchemy (default), Tortoise ORM, or Peewee
- ORM Adapter Pattern: Unified interface for all ORM operations through
BaseORMAdapter - ORMFactory: Factory class for creating and managing ORM adapters based on configuration
- Environment-based Configuration: Configure your ORM choice through environment variables (
ORM_TYPE) - Flexible Database Configuration: Support for different database URLs per ORM type
- Backward Compatibility: Existing SQLAlchemy code continues to work without changes
๐ง Improvements
- Modular Architecture: Clean separation of ORM-specific logic into adapters
- Better Code Organization: ORM adapters are now in a dedicated
ormpackage - Enhanced Configuration: Support for ORM-specific configuration through environment variables
- Improved Error Handling: Better error messages for missing ORM dependencies
- Code Quality: Improved code structure and maintainability
๐ฆ Dependencies
- FastAPI >= 0.76.0
- SQLAlchemy >= 1.4.36 (default, core dependency)
- Python >= 3.6
Optional Dependencies:
tortoise-orm>=0.20.0andasyncpg>=0.28.0for Tortoise ORM supportpeewee>=3.17.0for Peewee ORM support
๐งช Testing
- Comprehensive test suite with 200+ tests
- 70%+ code coverage
- Unit tests for all ORM adapters
- Integration tests for each ORM
- Edge case and error handling tests
- Both sync and async test coverage
๐ Documentation
- Updated README with multi-ORM configuration examples
- Added ORM adapter documentation
- Configuration examples for each supported ORM
- Migration guide for existing users
๐ Migration Guide
If you're upgrading from version 1.0.1:
-
No Breaking Changes: Existing code using SQLAlchemy will continue to work without modifications. SQLAlchemy remains the default ORM.
-
Using a Different ORM: To use Tortoise or Peewee, set the
ORM_TYPEenvironment variable:# For Tortoise ORM export ORM_TYPE=tortoise export DATABASE_URL=postgresql://user:pass@localhost/db export TORTOISE_MODELS=["app.models"] # For Peewee ORM export ORM_TYPE=peewee export DATABASE_URL=sqlite:///database.db -
Custom Adapter: You can now pass a custom
orm_adapterto viewsets:from fastapi_viewsets.orm.factory import ORMFactory adapter = ORMFactory.create_adapter('sqlalchemy', { 'database_url': 'postgresql://...' }) viewset = BaseViewset( model=User, orm_adapter=adapter, ... )
๐ ORM Adapters
The library now supports three ORM adapters:
-
SQLAlchemyAdapter (default)
- Full sync and async support
- Works with all SQLAlchemy-compatible databases
-
TortoiseAdapter
- Async-only ORM
- Perfect for high-performance async applications
- Requires
tortoise-ormand async database drivers
-
PeeweeAdapter
- Sync-only ORM
- Lightweight and simple
- Requires
peewee
๐ Configuration
Configure your ORM through environment variables in .env:
# Choose your ORM
ORM_TYPE=sqlalchemy # or 'tortoise' or 'peewee'
# Database URL (used by all ORMs)
DATABASE_URL=postgresql://user:pass@localhost/db
# SQLAlchemy-specific
SQLALCHEMY_DATABASE_URL=postgresql://user:pass@localhost/db
SQLALCHEMY_ASYNC_DATABASE_URL=postgresql+asyncpg://user:pass@localhost/db
# Tortoise-specific
TORTOISE_DATABASE_URL=postgresql://user:pass@localhost/db
TORTOISE_MODELS=["app.models", "app.other"]
TORTOISE_APP_LABEL=models
# Peewee-specific
PEEWEE_DATABASE_URL=sqlite:///database.db
๐ฆ Installation
pip install fastapi-viewsets
For specific ORM support:
# For Tortoise ORM
pip install fastapi-viewsets[tortoise]
# For Peewee ORM
pip install fastapi-viewsets[peewee]
๐ Links
Full Changelog: https://github.com/svalench/fastapi_viewsets/compare/v1.0.1...v1.1.0