Was this page helpful?
ScyllaDB Python Driver is available under the Apache v2 License. ScyllaDB Python Driver is a fork of DataStax Python Driver. See Copyright here.
Caution
You're viewing documentation for an unstable version of Scylla Python Driver. Switch to the latest stable version.
cassandra.cqlengine.columns
- Column types for object mapping models
cassandra.cqlengine.columns
- Column types for object mapping models¶Columns in your models map to columns in your CQL table. You define CQL columns by defining column attributes on your model classes. For a model to be valid it needs at least one primary key column and one non-primary key column.
Just as in CQL, the order you define your columns in is important, and is the same order they are defined in on a model’s corresponding table.
Each column on your model definitions needs to be an instance of a Column class.
bool flag, indicates this column is a primary key. The first primary key defined on a model is the partition key (unless partition keys are set), all others are cluster keys
indicates that this column should be the partition key, defining more than one partition key column creates a compound partition key
bool flag, indicates an index should be created for this column
bool flag, indicates an index is managed outside of cqlengine. This is useful if you want to do filter queries on fields that have custom indexes.
the fieldname this field will map to in the database
the default value, can be a value or a callable (no args)
boolean, is the field required? Model validation will raise and exception if required is set to True and there is a None value assigned
only applicable on clustering keys (primary keys that are not partition keys) determines the order that the clustering keys are sorted on disk
boolean, if set to True, this column will be used for discriminating records of inherited models.
Should only be set on a column of an abstract model being used for inheritance.
There may only be one discriminator column per model. See __discriminator_value__
for how to specify the value of this column on specialized models.
boolean, if set to True, this is a static column, with a single value per partition
Columns of all types are initialized by passing Column
attributes to the constructor by keyword.
Stores a US-ASCII character string
min_length (int) – Sets the minimum length of this string, for validation purposes.
Defaults to 1 if this is a required
column. Otherwise, None.
max_length (int) – Sets the maximum length of this string, for validation purposes.
Stores a 64-bit signed integer value
Stores a raw binary value
Stores a boolean True or False value
Stores a counter that can be incremented and decremented
Stores a simple date, with no time-of-day
Changed in version 2.6.0: removed overload of Date and DateTime. DateTime is a drop-in replacement for legacy models
requires C* 2.2+ and protocol v4+
Stores a datetime value
Set this True
to have model instances truncate the date, quantizing it in the same way it will be in the database.
This allows equality comparison between assigned values and values read back from the database:
DateTime.truncate_microseconds = True
assert Model.create(id=0, d=datetime.utcnow()) == Model.objects(id=0).first()
Defaults to False
to preserve legacy behavior. May change in the future.
Stores a variable precision decimal value
Stores a double-precision floating-point value
Stores a single-precision floating-point value
Stores a 32-bit signed integer value
Stores a list of ordered values
http://www.datastax.com/documentation/cql/3.1/cql/cql_using/use_list_t.html
value_type – a column class indicating the types of the value
Stores a key -> value map (dictionary)
https://docs.datastax.com/en/dse/6.7/cql/cql/cql_using/useMap.html
key_type – a column class indicating the types of the key
value_type – a column class indicating the types of the value
Stores a set of unordered, unique values
http://www.datastax.com/documentation/cql/3.1/cql/cql_using/use_set_t.html
value_type – a column class indicating the types of the value
strict – sets whether non set values will be coerced to set type on validation, or raise a validation error, defaults to True
Stores a 16-bit signed integer value
Added in version 2.6.0.
requires C* 2.2+ and protocol v4+
Stores a UTF-8 encoded string
min_length (int) – Sets the minimum length of this string, for validation purposes.
Defaults to 1 if this is a required
column. Otherwise, None.
max_length (int) – Sets the maximum length of this string, for validation purposes.
Stores a timezone-naive time-of-day, with nanosecond precision
Added in version 2.6.0.
requires C* 2.2+ and protocol v4+
UUID containing timestamp
Stores an 8-bit signed integer value
Added in version 2.6.0.
requires C* 2.2+ and protocol v4+
User Defined Type column
http://www.datastax.com/documentation/cql/3.1/cql/cql_using/cqlUseUDT.html
These columns are represented by a specialization of cassandra.cqlengine.usertype.UserType
.
Please see User Defined Types for examples and discussion.
user_type (type) – specifies the UserType
model of the column
Stores a type 1 or 4 UUID
Stores an arbitrary-precision integer
Was this page helpful?
ScyllaDB Python Driver is available under the Apache v2 License. ScyllaDB Python Driver is a fork of DataStax Python Driver. See Copyright here.
cassandra
- Exceptions and Enumscassandra.cluster
- Clusters and Sessionscassandra.policies
- Load balancing and Failure Handling Policiescassandra.auth
- Authenticationcassandra.metadata
- Schema and Ring Topologycassandra.metrics
- Performance Metricscassandra.query
- Prepared Statements, Batch Statements, Tracing, and Row Factoriescassandra.pool
- Hosts and Connection Poolscassandra.protocol
- Protocol Featurescassandra.encoder
- Encoders for non-prepared Statementscassandra.decoder
- Data Return Formatscassandra.concurrent
- Utilities for Concurrent Statement Executioncassandra.connection
- Low Level Connection Infocassandra.util
- Utilitiescassandra.timestamps
- Timestamp Generationcassandra.io.asyncioreactor
- asyncio
Event Loopcassandra.io.asyncorereactor
- asyncore
Event Loopcassandra.io.eventletreactor
- eventlet
-compatible Connectioncassandra.io.libevreactor
- libev
Event Loopcassandra.io.geventreactor
- gevent
-compatible Event Loopcassandra.io.twistedreactor
- Twisted Event Loopcassandra.cqlengine.models
- Table models for object mappingcassandra.cqlengine.columns
- Column types for object mapping modelscassandra.cqlengine.query
- Query and filter model objectscassandra.cqlengine.connection
- Connection management for cqlenginecassandra.cqlengine.management
- Schema management for cqlenginecassandra.cqlengine.usertype
- Model classes for User Defined Types