インストールとテスト

ほとんどのユーザーはPyPIでホストされている最新バージョンをインストールするだけです:

pip install peewee

Peeweeにはオプションでコンパイルできる2つのCエクステンションが付属しています:

  • Cythonで再実装されたその他の関数が含まれているSpeedupsモジュール。Cythonがインストールされている場合、このモジュールは自動的に構築されます。
  • Sqlite extensions, which includes Cython implementations of the SQLite date manipulation functions, the REGEXP operator, and full-text search result ranking algorithms. This module should be built using the build_sqlite_ext command.

注釈

Cythonがインストールされている場合は、 speedups モジュールが自動的に構築されます。SQLite Cythonエクステンションをビルドする場合は、手動で実行する必要があります:

python setup.py build_sqlite_ext
python setup.py install

gitでインストールする

このプロジェクトは https://github.com/coleifer/peewee にホストされていて、gitを使用してインストールできます:

git clone https://github.com/coleifer/peewee.git
cd peewee
python setup.py install

git checkoutでSQLite拡張機能をビルドしたい場合は、以下のように実行できます

# Build the sqlite extension and place the shared library alongside the other modules.
python setup.py build_sqlite_ext -i

注釈

いくつかのシステムではシステム全体にpeeweeをインストールするために``sudo python setup.py install`` を使用する必要があります。

テストの実行

テストスイートを実行してインストールをテストできます。

python setup.py test

# Or use the test runner:
python runtests.py

runtests.py スクリプトを使用して、特定の機能や特定のデータベースドライバをテストすることができます。デフォルトでは、テストスイートはSQLiteを使用して実行され、playhouse エクステンションのテストは実行されません。使用可能なテストランナーのオプションを表示するには、次のコマンドを使用します:

python runtests.py --help

Optional dependencies

注釈

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 psycopg2 for MySQL and Postgres respectively.

  • Cython: used for various speedups. Can give a big boost to certain operations, particularly if you use SQLite.
  • apsw: an optional 3rd-party SQLite binding offering greater performance and much, much saner semantics than the standard library pysqlite. Use with APSWDatabase.
  • pycrypto is used for the AESEncryptedField.
  • bcrypt module is used for the PasswordField.
  • vtfunc <https://github.com/coleifer/sqlite-vtfunc> is used to provide some table-valued functions for Sqlite as part of the sqlite_udf extensions module.
  • gevent is an optional dependency for SqliteQueueDatabase (though it works with threading just fine).
  • BerkeleyDB can be compiled with a SQLite frontend, which works with Peewee. Compiling can be tricky so here are instructions.
  • Lastly, if you use the Flask or Django frameworks, there are helper extension modules available.