I've a following ColumnFamily
class UniqueUserDealAction(models.Model):
deal_id = columns.Text(primary_key=True)
action = columns.Text(primary_key=True)
imei1 = columns.Text(primary_key=True)
imei2 = columns.Text(primary_key=True)
event_time = columns.DateTime()
created_at = columns.DateTime(default=datetime.now)
Whenever I try inserting data into the CF,
u = UniqueUserDealAction.create(deal_id='praful', action='India',
imei1='delhi', imei2='IT')
It returns me an error saying -
Traceback (most recent call last):
File "/home/praful/Desktop/cube/c26-analytics/test.py", line 7, in <module>
imei1='delhi', imei2='IT')
File "/usr/local/lib/python2.7/dist-packages/cassandra/cqlengine/models.py", line 583, in create
return cls.objects.create(**kwargs)
File "/usr/local/lib/python2.7/dist-packages/cassandra/cqlengine/query.py", line 715, in create
timestamp(self._timestamp).save()
File "/usr/local/lib/python2.7/dist-packages/cassandra/cqlengine/models.py", line 648, in save
timeout=self._timeout).save()
File "/usr/local/lib/python2.7/dist-packages/cassandra/cqlengine/query.py", line 1028, in __init__
self.column_family_name = self.model.column_family_name()
File "/usr/local/lib/python2.7/dist-packages/cassandra/cqlengine/models.py", line 483, in column_family_name
return '{0}.{1}'.format(protect_name(cls._get_keyspace()), cf_name)
File "cassandra/metadata.py", line 1231, in cassandra.metadata.protect_name (cassandra/metadata.c:27526)
File "cassandra/metadata.py", line 1260, in cassandra.metadata.maybe_escape_name (cassandra/metadata.c:28214)
File "cassandra/metadata.py", line 1264, in cassandra.metadata.escape_name (cassandra/metadata.c:28294)
AttributeError: 'NoneType' object has no attribute 'replace'
[Finished in 0.1s with exit code 1]
[shell_cmd: python -u "/home/praful/Desktop/cube/c26-analytics/test.py"]
[dir: /home/praful/Desktop/cube/c26-analytics]
[path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games]
UPDATE
This is how I'm creating my keyspaces and CF.
from cassandra.cqlengine import connection
from cassandra.cqlengine.management import sync_table, create_keyspace_simple
from models import UniqueUserDealAction
CQLENG_ALLOW_SCHEMA_MANAGEMENT = 'CQLENG_ALLOW_SCHEMA_MANAGEMENT'
CLUSTER_NODES = ['127.0.0.1']
connection.setup(CLUSTER_NODES, "mad")
create_keyspace_simple("mad", replication_factor=2)
sync_table(UniqueUserDealAction)