Peewee

Peewee

docs.peewee-orm.com

1

About this website

Peewee is a simple, lightweight, and expressive Object-Relational Mapping (ORM) library for Python, created and maintained by Charles Leifer. It is designed as a minimalist alternative to heavier ORMs like SQLAlchemy or Django ORM, focusing on a small footprint, intuitive API, and zero-configuration setup. Peewee is particularly well-suited for small to medium-sized projects, scripts, CLI tools, and embedded applications where the full power and complexity of a large ORM framework would be overkill. The entire library is contained in a single Python module (peewee.py, approximately 10,000 lines), with no external dependencies beyond the Python standard library and the database driver. Key features include: a declarative model definition syntax where database tables are represented as Python classes inheriting from the Model base class, with database columns defined as class attributes using Field types (CharField, IntegerField, DateTimeField, ForeignKeyField, ManyToManyField, and more), an expressive query builder using Python operator overloading (for example, User.select().where(User.username == 'admin') translates to a parameterized SQL query), support for joins and complex queries (with join() methods and the model_select pattern), support for aggregation (count, sum, avg, min, max), raw SQL queries for cases where the ORM is insufficient, transaction management via the database.atomic() context manager and the @database.transaction() decorator, connection pooling (via the PooledMySQLDatabase and PooledPostgresqlDatabase classes), schema migrations (via the playhouse.migrate module), support for SQLite, PostgreSQL, MySQL, and CockroachDB backends, full-text search support (via the playhouse.sqlite_ext module for SQLite FTS3/FTS4/FTS5), and JSON field support for document-oriented use cases. As of 2026, Peewee has over 11,000 GitHub stars.

Tags & Categories

Categories

Tags

Statistics

1
Views
0
Clicks
0
Like
0
Dislike

Comments

Log In to post a comment

No comments yet. Be the first!