Model definitions Creating test data Model definitions We’ll use the following model definitions for our examples: import datetime from peewee import * db = S...
Setting the database at run-time Setting the database at run-time We have seen three ways that databases can be configured with Peewee: # The usual way: db = SqliteDatabas...
Avoiding the N+1 problem List recent tweets List users and all their tweets Using prefetch Avoiding the N+1 problem The N+1 problem refers to a situation where an applicatio...
Adding a new Database Driver Adding a new Database Driver Peewee comes with built-in support for Postgres, MySQL and SQLite. These databases are very popular and run the gamut ...
Initializing a Database Initializing a Database The Database initialization method expects the name of the database as the first parameter. Subsequent keyword arguments are p...
Initializing a Database Initializing a Database The Database initialization method expects the name of the database as the first parameter. Subsequent keyword arguments are p...
Performing simple joins Performing simple joins As an exercise in learning how to perform joins with Peewee, let’s write aquery to print out all the tweets by “huey”. To do thi...
Querying Creating a new record Bulk inserts Updating existing records Atomic updates Deleting records Selecting a single record Create or get Selecting multiple records Fil...
Implementing Many to Many ManyToManyField Implementing Many to Many Peewee provides a field for representing many-to-many relationships, much like Django does. This feature wa...
Example app Running the example Diving into the code Models Creating tables Establishing a database connection Making queries Creating new objects Performing subqueries Othe...