在pycassa中指定列类型

时间:2013-05-07 15:05:53

标签: python cassandra pycassa

我想在pycassa中对这些CLI命令进行等效:

CREATE COLUMN FAMILY users
WITH comparator = UTF8Type
AND key_validation_class=UTF8Type
AND column_metadata = [
{column_name: full_name, validation_class: UTF8Type}
{column_name: email, validation_class: UTF8Type}
{column_name: state, validation_class: UTF8Type}
{column_name: gender, validation_class: UTF8Type}
{column_name: birth_year, validation_class: LongType}
];

pycassa的等价性是什么? 感谢

2 个答案:

答案 0 :(得分:2)

你可以试试这个。不太了解python客户端,还是......

 validators = {'full_name': UTF8_TYPE,
              'email': UTF8_TYPE,
              'state': UTF8_TYPE,
              'gender': UTF8_TYPE,
              'birth_year': LONG_TYPE}
 sys.create_column_family('TestKeyspace', 'TestCF', super=False,
              comparator_type=UTF8Type,
              key_validation_class=UTF8Type, 
              column_validation_classes=validators)

答案 1 :(得分:0)

回答你的另一个问题:     key_validation_class ='CompositeType(UTF8Type,UTF8Type)'