How coleifer/peewee works
Peewee is a compact Python ORM and SQL query builder. The principal workflow is application code defining models, composing queries, executing them through a database backend, and receiving mapped results. Model metadata is the key internal layer connecting declarations to SQL generation. Optional branches provide asyncio execution, SQLite full-text search, schema migration, database reflection/code generation, and framework/data-model integrations. The graph emphasizes documented capabilities and sampled runtime paths; some extension wiring is shown as optional where source excerpts were incomplete.
Main entry points: peewee.py Database Runtime · pwasyncio.py Async Database API · playhouse Framework Adapters · pydantic_utils.py Pydantic Adapter
Components 19
Core ORM
- Model API
peewee.py - Model Metadata
peewee.py - Query Builder
peewee.py - Result Mapping
peewee.py
Database Runtime
- Database Runtime
peewee.py - SQLite Database
- MySQL Database
- PostgreSQL Database
Runtime Extensions
- Async Database API
playhouse/pwasyncio.py - Async Drivers
- SQLite FTS
playhouse/sqlite_ext.py - FTS Query Parser
playhouse/fts_parser.py - Framework Adapters
playhouse - Pydantic Adapter
playhouse/pydantic_utils.py
Schema Tooling
- Migration Runner
playhouse/migrations.py - Schema Migrator
playhouse/migrate.py - Database Reflection
playhouse/reflection.py - Model Generator
pwiz.py
Other components
- Application Developer
Connections 25
- Application Developer → Model API: defines models
- Model API → Model Metadata: registers fields
- Model Metadata → Query Builder: describes models
- Application Developer → Query Builder: builds queries
- Query Builder → Database Runtime: executes SQL
- Database Runtime → SQLite Database: sends SQL
- Database Runtime → MySQL Database: sends SQL
- Database Runtime → PostgreSQL Database: sends SQL
- Database Runtime → Result Mapping: returns cursors
- Result Mapping → Application Developer: returns models
- Application Developer → Async Database API: awaits queries
- Async Database API → Async Drivers: uses drivers
- Async Database API → Result Mapping: buffers results
- Application Developer → SQLite FTS: searches text
- FTS Query Parser → SQLite FTS: produces query
- Application Developer → Migration Runner: runs migrations
- Migration Runner → Schema Migrator: runs operations
- Schema Migrator → Database Runtime: executes DDL
- Application Developer → Model Generator: generates models
- Model Generator → Database Reflection: inspects schema
- Database Reflection → Database Runtime: reads metadata
- Application Developer → Framework Adapters: integrates apps
- Framework Adapters → Model API: uses ORM
- Application Developer → Pydantic Adapter: serializes models
- Pydantic Adapter → Model API: reads models