1

如何在 django cassandra 模型中定义 varchar 字段。

from cassandra.cqlengine import columns
from django_cassandra_engine.models import DjangoCassandraModel

class ChatEvent(DjangoCassandraModel):
    interview_id = columns.UUID(partition_key=True)
    fire_time = columns.DateTime(primary_key=True, clustering_order="DESC")
    id = columns.UUID(primary_key=True)
    type = //to be varchar type
    data = columns.Text(required=True)
    created_by = columns.UUID(required=True)

本文档列出了所有数据类型,但没有 varchar 类型 https://docs.datastax.com/en/drivers/python/2.5/api/cassandra/cqlengine/columns.html#:~:text=Columns%20in %20your%20models%20map,one%20non%2Dprimary%20key%20column

4

1 回答 1

2

varchar是字段的别名(看这里text的答案),你需要使用CqlEngine的数据类型。Text

于 2020-10-23T07:58:42.853 回答