peewee
Attention
Peewee 3.0 has been released (you are looking at the 3.0 documentation). To see a list of backwards-incompatible changes, see the list of changes.
Peewee is a simple and small ORM. It has few (but expressive) concepts, making it easy to learn and intuitive to use.
- A small, expressive ORM
- Written in python with support for versions 2.7+ and 3.4+ (developed with 3.6)
- Built-in support for SQLite, MySQL and Postgresql.
- numerous extensions available (postgres hstore/json/arrays, sqlite full-text-search, schema migrations, and much more).
Peewee’s source code hosted on GitHub.
New to peewee? Here is a list of documents you might find most helpful when getting started:
- Quickstart guide – this guide covers all the bare essentials. It will take you between 5 and 10 minutes to go through it.
- Example Twitter app written using Flask framework.
- Guide to the various query operators describes how to construct queries and combine expressions.
- Field types table lists the various field types peewee supports and the parameters they accept. There is also an extension module that contains special/custom field types.
Contents:
- Installing and Testing
- Quickstart
- Example app
- Contributing
- Database
- Initializing a Database
- Using Postgresql
- Using SQLite
- Using MySQL
- Connecting using a Database URL
- Run-time database configuration
- Dynamically defining a database
- Connection Management
- Connection Pooling
- Testing Peewee Applications
- Async with Gevent
- Framework Integration
- Executing Queries
- Managing Transactions
- Database Errors
- Logging queries
- Adding a new Database Driver
- Models and Fields
- Querying
- Creating a new record
- Bulk inserts
- Updating existing records
- Atomic updates
- Deleting records
- Selecting a single record
- Create or get
- Selecting multiple records
- Filtering records
- Sorting records
- Getting random records
- Paginating records
- Counting records
- Aggregating records
- Retrieving Scalar Values
- Window functions
- Retrieving row tuples / dictionaries / namedtuples
- Returning Clause
- Foreign Keys and Joins
- Implementing Many to Many
- Self-joins
- Performance Techniques
- Query operators
- API Documentation
- SQLite Extensions
- Playhouse, extensions to Peewee
- Query Examples
- Query Builder
- Hacks
- Changes in 3.0
Note
If you find any bugs, odd behavior, or have an idea for a new feature please don’t hesitate to open an issue on GitHub or contact me.