Changes in 3.0
I tried to keep changes backwards-compatible as much as possible. In some places, APIs that have changed will trigger a .
get_conn()
has changed toDatabase.connection()
get_cursor()
has changed toexecution_context()
is replaced by simply using the database instance as a context-manager.- For a connection context without a transaction, use
Database.connection_context()
. - and
Database.drop_tables()
, as well as andModel.drop_table()
all default tosafe=True
(create_table
will create if not exists,drop_table
will drop if exists). connect_kwargs
attribute has been renamed toconnect_params
Model Meta options
db_table_func
has changed totable_function
order_by
has been removed (used for specifying a default ordering to be applied to SELECT queries).validate_backrefs
has been removed. Back-references are no longer validated.
Models
BaseModel
has been renamed toModelBase
- Accessing raw model data is now done using
__data__
instead of_data
db_column
has changed todb_field
class attribute changed tofield_type
(used if you are implementing custom field subclasses)model_class
attribute has changed tomodel
PrimaryKeyField
has been renamed toForeignKeyField
constructor has the following changes:rel_model
has changed tomodel
to_field
has changed tofield
related_name
has changed tobackref
- is now included in the main
peewee.py
module - Removed the extension fields
PasswordField
,PickledField
andAESEncryptedField
.
Querying
The C extension that contained implementations of the query result wrappers has been removed.
Additionally, Select.aggregate_rows()
has been removed. This helper was used to de-duplicate left-join queries to give the appearance of efficiency when iterating a model and its relations. In practice, the complexity of the code and its somewhat limited usefulness convinced me to scrap it. You can instead use to achieve the same result.
Select
query attribute_select
has changed to_returning
- The
naive()
method is now , which defaults to using the model class as the constructor, but accepts any callable to use as an alternate constructor.
The Case()
helper has moved from the module into the main peewee module.
The InsertQuery.return_id_list()
method has been replaced by a more general pattern of using .
When using prefetch()
, the collected instances will be stored in the same attribute as the foreign-key’s backref
. Previously, you would access joined instances using (backref)_prefetch
.
Removed Extensions
The following extensions are no longer included in the playhouse
:
berkeleydb
djpeewee
gfk
kv
pskel
read_slave
The SQLite extension module’s VirtualModel
class accepts slightly different Meta
options:
arguments
- used to specify arbitrary arguments appended after any columns being defined on the virtual table. Should be a list of strings.extension_module
(unchanged)options
(replacesextension_options
) - arbitrary options for the virtual table that appear after columns andarguments
.prefix_arguments
- a list of strings that should appear before any arguments or columns in the virtual table declaration.
Signals Extension
The post_init
signal has been removed.
New stuff
The query-builder has been rewritten from the ground-up to be more flexible and powerful. There is now a generic, for constructing queries.
SQLite
Many SQLite-specific features have been moved from the playhouse.sqlite_ext
module into peewee
, such as:
- User-defined functions, aggregates, collations, and table-functions.
- Loading extensions.
- Specifying pragmas.
See the and “SQLite extensions” documents for more details.
- Support for SQLite online backup API.
- Murmurhash implementation has been corrected.
- Couple small quirks in the BM25 ranking code have been addressed.
- Numerous user-defined functions for hashing and ranking are now included.
BloomFilter
implementation.- Incremental I/O support.
LSMTable
implementation to support the lsm1 extension.