- Peewee - Discussion
- Peewee - Useful Resources
- Peewee - Quick Guide
- Peewee - Using CockroachDB
- Peewee - PostgreSQL & MySQL Extensions
- Peewee - SQLite Extensions
- Peewee - Integration with Web Frameworks
- Peewee - Query Builder
- Peewee - Database Errors
- Peewee - Atomic Transactions
- Peewee - User defined Operators
- Peewee - Retrieving Row Tuples/Dictionaries
- Peewee - SQL Functions
- Peewee - Counting & Aggregation
- Peewee - Sorting
- Peewee - Subqueries
- Peewee - Relationships & Joins
- Peewee - Connection Management
- Peewee - Defining Database Dynamically
- Peewee - Using PostgreSQL
- Peewee - Using MySQL
- Peewee - Constraints
- Peewee - Create Index
- Peewee - Delete Records
- Peewee - Update Existing Records
- Peewee - Primary & Composite Keys
- Peewee - Filters
- Peewee - Select Records
- Peewee - Insert a New Record
- Peewee - Field Class
- Peewee - Model
- Peewee - Database Class
- Peewee - Overview
- Peewee - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Peewee - SQLite Extensions
Peewee comes with a Playhouse namespace. It is a collection of various extension modules. One of them is a playhouse.sqpte_ext module. It mainly defines SqpteExtDatabase class which inherits SqpteDatabase class, supports following additional features −
Features of SQLite Extensions
The features of SQLite Extensions which are supported by Peewee are as follows −
Full-text search.
JavaScript Object Notation (JSON) extension integration.
Closure table extension support.
LSM1 extension support.
User-defined table functions.
Support for onpne backups using backup API: backup_to_file().
BLOB API support, for efficient binary data storage.
JSON data can be stored, if a special JSONField is declared as one of the field attributes.
class MyModel(Model): json_data = JSONField(json_dumps=my_json_dumps)
To activate full-text search, the model can have DocIdField to define primary key.
class NoteIndex(FTSModel): docid = DocIDField() content = SearchField() class Meta: database = db
FTSModel is a Subclass of VirtualModel which is available at
to be used with the FTS3 and FTS4 full-text search extensions. Sqpte will treat all column types as TEXT (although, you can store other data types, Sqpte will treat them as text).SearchField is a Field-class to be used for columns on models representing full-text search virtual tables.
SqpteDatabase supports AutoField for increasing primary key. However, SqpteExtDatabase supports AutoIncrementField to ensure that primary always increases monotonically, irrespective of row deletions.
SqpteQ module in playhouse namespace (playhouse.sqpteq) defines subclass of SqpteExeDatabase to handle seriapsed concurrent writes to a SQpte database.
On the other hand, playhouse.apsw module carries support for apsw sqpte driver. Another Python SQLite Wrapper (APSW) is fast and can handle nested transactions, that are managed exppcitly by you code.
from apsw_ext import * db = APSWDatabase( testdb ) class BaseModel(Model): class Meta: database = db class MyModel(BaseModel): field1 = CharField() field2 = DateTimeField()Advertisements