API Reference
Peewee
A small, expressive ORM for Python supporting SQLite, PostgreSQL, and MySQL with a concise query API.
Official Documentation ↗CompatibilityThis documentation covers version
v4.5.3. Check the official docs for the latest API surface.Installation
pip
pip install peeweeMethods
No methods match this filter.
Peewee maps Python classes to tables and builds SQL from model fields and query expressions.
Key Features
- Small footprint with a clean model API
- Multiple SQL backends including SQLite
- Query expressions and transactions
Usage Notes
Pin a version and check the official docs for the API surface you depend on before upgrading.
Errors
The official API reference declares the following error types:
peewee.DoesNotExist(exception) — official text: “class DoesNotExist — Base exception class raised when a call to Model.get() (or other .get() method) fails to return a matching result.” (source: https://docs.peewee-orm.com/en/latest/peewee/api.html#DoesNotExist, fetched 2026-11-08T16:03:08.4363995+08:00)peewee.IntegrityError(exception) — official text: “class IntegrityError” (source: https://docs.peewee-orm.com/en/latest/peewee/api.html#IntegrityError, fetched 2026-11-08T16:03:08.4363995+08:00)
API reference evidence
Fetched from official sources on 2026-11-08T16:03:08.4363995+08:00 via WebFetch 官方 API 页面(Model / Database / exceptions 章节).
peewee.Model→ signature from https://docs.peewee-orm.com/en/latest/peewee/api.html#Model; official text: “class Model(**kwargs) — Parameters kwargs – Mapping of field-name to value to initialize model with.”Model.create→ signature from https://docs.peewee-orm.com/en/latest/peewee/api.html#Model.create; official text: “classmethod create(**query) — INSERT new row into table and return corresponding model instance.”Model.select→ signature from https://docs.peewee-orm.com/en/latest/peewee/api.html#Model.select; official text: “classmethod select(*fields) — Create a SELECT query. If no fields are explicitly provided, the query will by default select all columns for the given model.”
FAQ
- How do I create the tables?
- Call db.create_tables([User]) after defining models, or use playhouse.migrate for schema changes.
- How are transactions handled?
- Use with db.atomic(): to group writes; the block commits on success and rolls back on exception.
- Does it support async?
- Not natively. Peewee is synchronous; run it in a thread for async apps, or use a different ORM for asyncio.
Report a problem with this API docOpens a pre-filled issue on GitHub.