This is an overview of things that changed as the cqlengine project was merged into scylla-driver. While efforts were taken to preserve the API and most functionality exactly, conversion to this package will still require certain minimal updates (namely, imports).
THERE IS ONE FUNCTIONAL CHANGE, described in the first section below.
Legacy cqlengine included a workaround for a Cassandra bug in which prepended list segments were reversed (CASSANDRA-8733). As of this integration, this workaround is removed. The first released integrated version emits a warning when prepend is used. Subsequent versions will have this warning removed.
The Date column type in legacy cqlengine used a
timestamp CQL type and truncated the time.
Going forward, the
Date type represents a
date for Cassandra 2.2+
Users of the legacy functionality should convert models to use
timestamp internally), and use the build-in
datetime.date for input values.
To avoid confusion or mistakes using the legacy package in your application, it is prudent to remove the cqlengine package when upgrading to the integrated version.
The driver setup script will warn if the legacy package is detected during install, but it will not prevent side-by-side installation.
cqlengine is now integrated as a sub-package of the driver base package ‘cassandra’. Upgrading will require adjusting imports to cqlengine. For example:
from cassandra.cqlengine import columns
from cassandra.cqlengine import columns
Legacy cqlengine defined a number of aliases at the package level, which became redundant
when the package was integrated for a driver. These have been removed in favor of absolute
imports, and referring to cannonical definitions. For example,
cqlengine.ONE was an alias
cassandra.ConsistencyLevel.ONE. In the integrated package, only the
Additionally, submodule aliases are removed from cqlengine in favor of absolute imports.
These aliases are removed, and not deprecated because they should be straightforward to iron out at module load time.
The legacy cqlengine.exceptions module had a number of Exception classes that were variously common to the package, or only used in specific modules. Common exceptions were relocated to cqlengine, and specialized exceptions were placed in the module that raises them. Below is a listing of updated locations:
class UnicodeMixin was defined in several cqlengine modules. This has been consolidated
to a single definition in the cqlengine package init file. This is not technically part of
the API, but noted here for completeness.
This upgrade served as a good juncture to deprecate certain API features and invite users to upgrade to new ones. The first released version does not change functionality – only introduces deprecation warnings. Future releases will remove these features in favor of the alternatives.
Previously there was no
Double column type. Doubles were modeled by specifying
This inititializer parameter is now deprecated. Applications should use
Double for CQL
cassandra.cqlengine.management.create_keyspace is deprecated. Instead, use the new replication-strategy-specific
functions that accept explicit options for known strategies:
cassandra.cqlengine.management.delete_keyspace is deprecated in favor of a new function,
intent is simply to make the function match the CQL verb it invokes.
The names for class attributes controlling model inheritance are changing. Changes are as follows:
Replace ‘polymorphic_key’ in the base class Column definition with
Replace the ‘__polymorphic_key__’ class attribute the derived classes with
The functionality is unchanged – the intent here is to make the names and language around these attributes more precise. For now, the old names are just deprecated, and the mapper will emit warnings if they are used. The old names will be removed in a future version.
The example below shows a simple translation:
class Pet(Model): __table_name__ = 'pet' owner_id = UUID(primary_key=True) pet_id = UUID(primary_key=True) pet_type = Text(polymorphic_key=True) name = Text() class Cat(Pet): __polymorphic_key__ = 'cat' class Dog(Pet): __polymorphic_key__ = 'dog'
class Pet(models.Model): __table_name__ = 'pet' owner_id = UUID(primary_key=True) pet_id = UUID(primary_key=True) pet_type = Text(discriminator_column=True) name = Text() class Cat(Pet): __discriminator_value__ = 'cat' class Dog(Pet): __discriminator_value__ = 'dog'
This function is deprecated in favor of the core utility function
cassandra- Exceptions and Enums
cassandra.cluster- Clusters and Sessions
cassandra.policies- Load balancing and Failure Handling Policies
cassandra.graph- Graph Statements, Options, and Row Factories
cassandra.metadata- Schema and Ring Topology
cassandra.metrics- Performance Metrics
cassandra.query- Prepared Statements, Batch Statements, Tracing, and Row Factories
cassandra.pool- Hosts and Connection Pools
cassandra.protocol- Protocol Features
cassandra.encoder- Encoders for non-prepared Statements
cassandra.decoder- Data Return Formats
cassandra.concurrent- Utilities for Concurrent Statement Execution
cassandra.connection- Low Level Connection Info
cassandra.timestamps- Timestamp Generation
gevent-compatible Event Loop
cassandra.io.twistedreactor- Twisted Event Loop
cassandra.cqlengine.models- Table models for object mapping
cassandra.cqlengine.columns- Column types for object mapping models
cassandra.cqlengine.query- Query and filter model objects
cassandra.cqlengine.connection- Connection management for cqlengine
cassandra.cqlengine.management- Schema management for cqlengine
cassandra.cqlengine.usertype- Model classes for User Defined Types
cassandra.datastax.graph- Graph Statements, Options, and Row Factories