Database Module
The Database module wraps SQLAlchemy async with intelligent query planning, N+1 query detection, automatic relationship loading, and performance modes. It provides a high-level repository pattern for common operations.
Configuration
example.py
python
Copied!
Performance Modes
| Mode | Pooling | Prepared Statements | N+1 Detection |
|---|---|---|---|
development | Small pool | Disabled | Enabled with warnings |
balanced | Medium pool | Enabled | Enabled with logging |
production | Large pool | Enabled | Disabled |
Basic Usage
list_users.py
python
Copied!
Repository Pattern
base.py
python
Copied!
N+1 Query Detection
The database module monitors queries within a request and detects N+1 patterns. When enabled, it logs warnings with the offending query sequence and suggests eager loading strategies.
schema.sql
sql
Copied!
select_related and prefetch
list_users_with_posts.py
python
Copied!
Query Planning
Vorte analyzes query patterns and generates optimized execution plans. It caches frequently used query plans and suggests indexes.
example.py
python
Copied!
Migrations
terminal
bash
Copied!
Transactions
create_order.py
python
Copied!