Peewee(Python ORM 框架)知识点
资料 | 网址 |
---|---|
字段类型表 | https://www.osgeo.cn/peewee/peewee/models.html#field-types-table , http://docs.peewee-orm.com/en/latest/peewee/models.html#field-types-table |
中文网站 | https://www.osgeo.cn/peewee/peewee/query_examples.html#query-examples |
《Peewee 3.13.1 Document》 - 书栈网 | https://www.bookstack.cn/read/peewee-orm-3.13.1-en/README.md |
官方网站 | http://docs.peewee-orm.com/en/latest/ |
Playhouse, extensions to Peewee | http://docs.peewee-orm.com/en/latest/peewee/playhouse.html |
官方github | https://github.com/coleifer/peewee |
Managing Transactions
http://docs.peewee-orm.com/en/latest/peewee/database.html#managing-transactions
- 推荐使用atomic()
If you attempt to nest transactions with peewee using the transaction() context manager, only the outer-most transaction will be used. However if an exception occurs in a nested block, this can lead to unpredictable behavior, so it is strongly recommended that you use atomic(). - transaction在手动commit/rollback后,会自动产生一个新事务;savepoint不会
If you manually commit or roll back a savepoint, a new savepoint will not automatically be created. This differs from the behavior of transaction, which will automatically open a new transaction after manual commit/rollback. - Autocommit Mode:自动提交模式
By default, Peewee operates in autocommit mode, such that any statements executed outside of a transaction are run in their own transaction. To group multiple statements into a transaction, Peewee provides the atomic() context-manager/decorator. This should cover all use-cases, but in the unlikely event you want to temporarily disable Peewee’s transaction management completely, you can use the Database.manual_commit() context-manager/decorator.