2.8. SQLAlchemy Template

The SQLAlchemy Template provides a DatabasePort adapter backed by SQLAlchemy, giving your project a real relational database connection instead of the zero-dependency, in-memory storage every fresh project starts with.

It’s an interchangeable template: install it on its own to replace the in-memory default, or alongside MongoDB — config/app.toml’s default_database_adapter picks which one backs the generic default when both are installed, and code that specifically wants SQLAlchemy can use it directly regardless of that setting.

2.8.1. What it adds

  • A real database connection, configured through its own config/database.toml (connection string, pool settings).

  • ORM models and filter translation so the domain’s engine-agnostic filters (EqualFilter, LikeFilter, …) work against a real SQL database.

  • Introspection tools: python run database lists tables and columns of the connected database.

2.8.2. Combining with Flask

If the Flask Template (or flask_api/flask_ui) is also installed, it detects SQLAlchemy automatically and wires up the database connection for you — no extra configuration needed. Without SQLAlchemy, a Flask-based project still runs fine, just without persistence.