Well,
session "should" be a "global" variable, but keep in mind that
everytime you call commit, you are recreating session.

2013/7/18 Victor Reichert <vfr...@gmail.com>:
> HI All,
>
> I'm working on my first SQL Alchemy project.  I'm thinking I'm going to
> define a commit method for all the objects I want persist, I'm thinking
> something like:
>
>     def commit(self):
>         session = Session() #Session is a global sessionmaker
>         session.add(self)
>         session.commit()
>         session.close()
>
> Is that a good practice?
>
> Thank you for the advice :)
>
> ~Victor
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



-- 
Mauricio de Abreu Antunes
Mobile: (51)930-74-525
Skype: mauricio.abreua

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to