0

I am trying the new cqlengine models as part of the datastax driver. , here I am not able get the table_name from the class

from cassandra.cqlengine.models import Model

class User(Model):
    uid         = columns.UUID(primary_key=True,default=uuid.uuid4)
    fname       = columns.Text(primary_key=True,required=True)
    lname       = columns.Text(primary_key=True,required=True)
    user_id     = columns.Text(primary_key=True,required=True)
    email_id    = columns.Text(primary_key=True,required=True)
    password    = columns.Text(primary_key=True,required=True)
    salt        = columns.Text(required=True)

User.table_name gives me None.

Do I need to set this ?

From the documentation

Model.table_name

Optional. Sets the name of the CQL table for this model. If left blank, the table name will be the name of the model, with it’s module name as it’s prefix. Manually defined table names are not inherited.

Srikan
  • 2,161
  • 5
  • 21
  • 36

1 Answers1

2

As answered on the mailing list, considering the __table_name__ can also be dynamically computed based on the name of the model, the way to get the table name is using User.column_family_name(include_keypspace=False).

Alex Popescu
  • 3,982
  • 18
  • 20
  • @Popescu, thanks. It works. But you have a typo on `include_keypspace`. It should be `include_keyspace` – mtoloo Feb 17 '19 at 12:32