Model __table_name__ empty

19 views
Skip to first unread message

Srikanth Bemineni

unread,
Mar 13, 2016, 6:23:48 PM3/13/16
to DataStax Python Driver for Apache Cassandra User Mailing List
Hi.

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 ?

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.



Srikanth

Alan Boudreault

unread,
Mar 14, 2016, 8:32:11 AM3/14/16
to python-dr...@lists.datastax.com
Hello,

You don't need to set this attributes. The table name will be automatically set to "user" in your case.

Thanks,
Alan


--
You received this message because you are subscribed to the Google Groups "DataStax Python Driver for Apache Cassandra User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-driver-u...@lists.datastax.com.



--

Alan Boudreault
Software Engineer (Drivers and Tools) | alan.bo...@datastax.com

Srikanth Bemineni

unread,
Mar 16, 2016, 11:16:07 PM3/16/16
to DataStax Python Driver for Apache Cassandra User Mailing List
Hi Alan,

No, it is still showing as None. The __table_name__ is not set to User

With regards
Srikanth Bemineni

Alex Popescu

unread,
Mar 17, 2016, 12:33:55 AM3/17/16
to python-dr...@lists.datastax.com

On Wed, Mar 16, 2016 at 8:16 PM, Srikanth Bemineni <bemineni...@gmail.com> wrote:
__table_name__

Srikanth,

Why do you need to access __table_name__? You can do User.column_family_name(include_keypspace=False)


--
Bests,

Alex Popescu | @al3xandru
Sen. Product Manager @ DataStax

Srikanth Bemineni

unread,
Mar 20, 2016, 9:11:04 PM3/20/16
to DataStax Python Driver for Apache Cassandra User Mailing List
Hi,

I can use that, but in the first place why __table_name__ seems to be not working.

Srikanth 

Adam Holmberg

unread,
Mar 21, 2016, 9:56:52 AM3/21/16
to python-dr...@lists.datastax.com
I think it's working as intended. This optional attribute is used to specify the table name by defining it on the table.
We don't set any of those double-underscore class attributes after model definition.

The actual table name for a model is taken from that attribute or derived from the class name. Model.get_column_family_name is the way to get the actual table name.

Adam Holmberg

Reply all
Reply to author
Forward
0 new messages