A light object-relational mapper for scripts and small applications, from model to migration.
Before this guide: Object-Oriented Python.
The notebooks
Open in Colab runs a notebook in your browser, and Read shows it on GitHub without running it. Every notebook runs on its own, and the answers to its exercises are in a separate notebook, linked as Solutions.
| 1 | Why PeeweeA single peewee.py module with no required dependencies, and the cases where SQLAlchemy wins | Open in ColabReadSolutions |
| 2 | Models and FieldsMeta.database, create_tables, and the model that was bound to no database at all | Open in ColabReadSolutions |
| 3 | Creating and Changing Rowscreate, save, insert_many, and the save() that silently inserted nothing | Open in ColabReadSolutions |
| 4 | Selecting Rowswhere, order_by, fn.COUNT, and the and that quietly dropped half your filter | Open in ColabReadSolutions |
| 5 | Transactionsatomic, savepoints, and the exception you caught that committed anyway | Open in ColabReadSolutions |
| 6 | RelationshipsForeignKeyField, backref, and the join that still ran one query per row | Open in ColabReadSolutions |
| 7 | prefetch and LoadLoad, per_parent, and the backref that no join can flatten | Open in ColabReadSolutions |
| 8 | JSON ColumnsJSONField, path queries, and the numeric filter that compared JSON text until as_int() | Open in ColabReadSolutions |
| 9 | FTS5Model and SearchFieldSearchField, web_query, and the search box that is secretly a query language | Open in ColabReadSolutions |
| 10 | Migrationspwmigrate, the schema diff, and the down() nobody tested | Open in ColabReadSolutions |
| 11 | SQLite and PostgreSQLOne models module, two backends, and the SQL that changes when you swap the URL | Open in ColabReadSolutions |
| 12 | A Small CatalogModels, migrations, search, and what the backend switch costs the ranking | Open in ColabReadSolutions |