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.
[email protected] wrote:
> I am using declarative style models and very much happy about it.
>
> 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)
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/sqlalchemy?hl=en.
>
>
>
>
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.