Installing and Testing
Peewee comes with a couple C extensions that will be built if Cython is available.
- Speedups, which includes miscellaneous functions re-implemented with Cython.
- Sqlite extensions, which includes Cython implementations of the SQLite date manipulation functions, the REGEXP operator, and full-text search result ranking algorithms.
The project is hosted at https://github.com/coleifer/peewee and can be installed using git:
cd peewee
python setup.py install
Note
If you would like to build the SQLite extension in a git checkout, you can run:
You can test your installation by running the test suite.
python runtests.py
You can test specific features or specific database drivers using the script. To view the available test runner options, use:
To run tests against Postgres or MySQL you need to create a database named “peewee_test”. To test the Postgres extension module, you will also want to install the HStore extension in the postgres test database:
-- install the hstore extension on the peewee_test postgres db.
CREATE EXTENSION hstore;
Note
To use Peewee, you typically won’t need anything outside the standard library, since most Python distributions are compiled with SQLite support. You can test by running import sqlite3
in the Python console. If you wish to use another database, there are many DB-API 2.0-compatible drivers out there, such as pymysql
or for MySQL and Postgres respectively.
- : an optional 3rd-party SQLite binding offering greater performance and much, much saner semantics than the standard library
pysqlite
. Use withAPSWDatabase
. - sweepea <; is used to provide some table-valued functions for Sqlite as part of the
sqlite_udf
extensions module. Alternatively, you can also use vtfunc <https://github.com/coleifer/sqlite-vtfunc>, which is a smaller module that provides the same functionality. - is an optional dependency for
SqliteQueueDatabase
(though it works with just fine). - BerkeleyDB can be compiled with a SQLite frontend, which works with Peewee. Compiling can be tricky so .
- Lastly, if you use the Flask framework, there are helper extension modules available.