cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aikip...@gmail.com (Юрий Пухальский)
Subject AttributeError python exception when using Models
Date Sun, 06 Dec 2015 13:05:33 GMT
Good day, everyone!

I'm using 2.7.2 python driver from gentoo portage.
When I use traditional inserts and selects within my program, it works ok. But when I try
to use models, the program fails with an exception.

Here's the minimal program (I'm very new to cassandra, so maybe I'm missing something very
important):

#!/usr/bin/python

import logging

from cassandra.cqlengine import columns
from cassandra.cqlengine.models import Model
from cassandra.cqlengine.management import sync_table

from cassandra.cluster import Cluster

logging.basicConfig(format='%(asctime)s: %(message)s',
                    datefmt="%H:%M:%S", level=logging.WARNING)

cl_ips= [] # Removed for the post

cluster = Cluster(cl_ips)
session = cluster.connect('skipped')

class Tst(Model):
    field=columns.Text(primary_key=True)
    field1=columns.Text()

if False:
    sync_table(Tst)
    exit()

if True:
    tst=Tst.create(field='aaa', field1='bbb')
    tst.save()

Whether I do sync or try to update the already existing table, it fails:

Traceback (most recent call last):
  File "./test.py", line 33, in <module>
    tst=Tst.create(field='aaa', field1='bbb')
  File "/usr/lib64/python3.4/site-packages/cassandra/cqlengine/models.py", line 612, in create
    return cls.objects.create(**kwargs)
  File "/usr/lib64/python3.4/site-packages/cassandra/cqlengine/query.py", line 715, in create
    timestamp(self._timestamp).save()
  File "/usr/lib64/python3.4/site-packages/cassandra/cqlengine/models.py", line 677, in save
    timeout=self._timeout).save()
  File "/usr/lib64/python3.4/site-packages/cassandra/cqlengine/query.py", line 1028, in __init__
    self.column_family_name = self.model.column_family_name()
  File "/usr/lib64/python3.4/site-packages/cassandra/cqlengine/models.py", line 512, in column_family_name
    return '{0}.{1}'.format(protect_name(cls._get_keyspace()), cf_name)
  File "cassandra/metadata.py", line 1425, in cassandra.metadata.protect_name (cassandra/metadata.c:30775)
  File "cassandra/metadata.py", line 1459, in cassandra.metadata.maybe_escape_name (cassandra/metadata.c:31554)
  File "cassandra/metadata.py", line 1463, in cassandra.metadata.escape_name (cassandra/metadata.c:31634)
AttributeError: 'NoneType' object has no attribute 'replace'

I've tried to google for the similar problem, but couldn't find anything close.
Can you please direct me where to look for the roots of this problem?

Mime
View raw message