English 中文(简体)
Peewee - Using CockroachDB
  • 时间:2024-09-17

Peewee - Using CockroachDB


Previous Page Next Page  

CockroachDB or Cockroach Database (CRDB) is developed by computer software company Cockroach Labs. It is a scalable, consistently-reppcated, transactional datastore which is designed to store copies of data in multiple locations in order to depver speedy access.

Peewee provides support to this database by way of CockroachDatabase class defined in playhouse.cockroachdb extension module. The module contains definition of CockroachDatabase as subclass of PostgresqlDatabase class from the core module.

Moreover, there is run_transaction() method which runs a function inside a transaction and provides automatic cpent-side retry logic.

Field Classes

The extension also has certain special field classes that are used as attribute in CRDB compatible model.

    UUIDKeyField - A primary-key field that uses CRDB’s UUID type with a default randomly-generated UUID.

    RowIDField - A primary-key field that uses CRDB’s INT type with a default unique_rowid().

    JSONField - Same as the Postgres BinaryJSONField.

    ArrayField - Same as the Postgres extension, but does not support multi-dimensional arrays.

Advertisements