On Nov 10, 2008, at 11:22 AM, mg wrote:

>
> I am wondering which of these is the better pattern to use:
>
> metadata = MetaData()
> engine = create_engine(DEV_URL, echo=False,pool_size=1)
> Session = scoped_session(sessionmaker(bind=engine))
> session = Session()
>
> or:
>
> metadata = MetaData()
> engine = create_engine(DEV_URL, echo=False,pool_size=1)
> Session = scoped_session(sessionmaker())
> session = Session()
> metadata.bind = engine
>
> I am leaning towards the first. Where I work, we are in the middle of
> working on a project to split our data over mulitple database servers.
> As a result, I thought it would be better to have one session per
> database. If I am understanding correctly, I can then use one table
> definition to query against different database sessions.


use the first way, its more flexible for multiple databases as you're  
using and more appropriate for an ORM-centric application.  The second  
way is more advantageous when you are working with ad-hoc non-ORM SQL  
expressions that you'd like to execute without passing around a  
connection, which is known as "implicit connectionless execution".


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to