Saves an object to the database. .. code-block:: python #create a person instance person = Person(first_name='Kimberly', last_name='Eggleston') #saves it to Cassandra person.save()
(self)
| 710 | return self |
| 711 | |
| 712 | def save(self): |
| 713 | """ |
| 714 | Saves an object to the database. |
| 715 | |
| 716 | .. code-block:: python |
| 717 | |
| 718 | #create a person instance |
| 719 | person = Person(first_name='Kimberly', last_name='Eggleston') |
| 720 | #saves it to Cassandra |
| 721 | person.save() |
| 722 | """ |
| 723 | |
| 724 | # handle polymorphic models |
| 725 | if self._is_polymorphic: |
| 726 | if self._is_polymorphic_base: |
| 727 | raise PolymorphicModelException('cannot save polymorphic base model') |
| 728 | else: |
| 729 | setattr(self, self._discriminator_column_name, self.__discriminator_value__) |
| 730 | |
| 731 | self.validate() |
| 732 | self.__dmlquery__(self.__class__, self, |
| 733 | batch=self._batch, |
| 734 | ttl=self._ttl, |
| 735 | timestamp=self._timestamp, |
| 736 | consistency=self.__consistency__, |
| 737 | if_not_exists=self._if_not_exists, |
| 738 | conditional=self._conditional, |
| 739 | timeout=self._timeout, |
| 740 | if_exists=self._if_exists).save() |
| 741 | |
| 742 | self._set_persisted() |
| 743 | |
| 744 | self._timestamp = None |
| 745 | |
| 746 | return self |
| 747 | |
| 748 | def update(self, **values): |
| 749 | """ |
nothing calls this directly
no test coverage detected