pythondjangocassandra-2.0cqlengine

How do I represent a cassandra user defined type in a python model in cqlengine


I have the following table schema defined in my cassandra cluster

CREATE TABLE users (
username text PRIMARY KEY,
creationdate bigint,
email text,
firstlogin boolean,
firstname text,
lastloggedin bigint,
lastname text,
lastprofileupdate bigint,
name text,
olduserid int,
profile frozen<profile_type>,
user_id uuid

and the user defined type, profile_type as the below...

CREATE TYPE profile_type (
birthdate timestamp,
gender text,
title text,
relationshipstatus text,
homecountry text,
currentcountry text,
timezone text,
profilepicture blob,
alternate_email text,
religion text,
interests list<text>,
cellphone text,
biography text
);

How do I represent this structure as a cqlengine model? I'm particularly interested in the user defined type representation as i do not see any column definitions to represent such? Do i then need to map this manually? So far I have this in python....

class User(Model):
    username = columns.Text(primary_key=True)
    firstname = columns.Text(required=True)
    lastname = columns.Text(required=True)
    email = columns.Text(required=True)
    name = columns.Text(required=False)
    olduserid = columns.Integer()
    user_id = columns.UUID(default=uuid.uuid4)
    creationdate = columns.BigInt()

Solution

  • Apparently, this feature is not yet supported in cqlengine and there is development towards providing this in the near future. So for the time being, its back to utlizing the cassandra python driver provided by datastax to have this working in the code. I'll be looking out for when the cqlengine implementation is available and feed back here.