我遵循了cassandra Cquengine教程。在
import uuid
from cassandra.cqlengine import columns
from cassandra.cqlengine import connection
from datetime import datetime
from cassandra.cqlengine.management import sync_table
from cassandra.cqlengine.models import Model
class ExampleModel(Model):
example_id = columns.UUID(primary_key=True, default=uuid.uuid4)
example_type = columns.Integer(index=True)
created_at = columns.DateTime()
description = columns.Text(required=False)
connection.setup(['127.0.0.1'], "cqlengine", protocol_version=3)
sync_table(ExampleModel)
但是,当我更改模型中的字段时,例如,如果我将字段描述从文本类型更改为整数类型,然后执行sync_表,则在cassandra的表模式中看不到该更改。如何解决这个问题?在
这里有两个问题:
从概念上讲,您正在尝试模式迁移。python的apachecassandra驱动程序还没有正式支持模式迁移。快速浏览一下this ticket就可以解释我的意思了。{/严格地说,你的表{/cd2>是一个新的操作(注意,{/cd2>将不能正常工作)
数据模型中的Cassandra数据类型转换必须遵循CQL类型兼容性,这是定义的here。从
Integer
转换为Float
的尝试不兼容。到目前为止,使用不兼容类型更新架构的唯一解决方案是here。我就同一个here展开了单独的讨论。在
相关问题 更多 >
编程相关推荐