I see __table__ contains the classic sa.Table reference for advanced
queries. Like that do we have session is attached to the model class
derived from declarative_base?
I am very much curious to make django/rail style save, update, delete
methods on top of sqlalchemy.
I don't know much about Exlir but I see it does things over smart
matching some ruby like stuff. Not sure about community support.
If the session is attached, I can say like
class MyModel(SQLAlchemyDecBase)
...
def save(self):
self.session.add(self)
#or
meta.session.add(self)
Here's sample code I use:
def save(self, flush=False):
self.session.add(self)
if flush:
self.session.flush()
def delete(self):
self.session.delete(self)
Serge.
> --
>
> You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
> To post to this group, send email to sqlal...@googlegroups.com.
> To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
>
>
>
>
Regards,
Krish
On Dec 27, 2:19 pm, Serge Koval <serge.ko...@gmail.com> wrote:
> You can always do self.session.add(self) in save() without checks. If
> your model was already associated with the session before, it won't add
> it again.
>
> Here's sample code I use:
>
> def save(self, flush=False):
> self.session.add(self)
>
> if flush:
> self.session.flush()
>
> def delete(self):
> self.session.delete(self)
>
> Serge.
>