如何在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=列%20in%20your%20models%20map,一个%20non%2dprimary%20key%20column。
1条答案
按热度按时间wdebmtf21#
varchar
是的别名text
字段(请参阅此处的答案),您需要使用cqlengine的Text
数据类型。