Why bother wrapping sqlalchemy.engine_from_config? That part seems to take 
up most of the code in add_engine(), but when a user has an oddball database 
they have to read and understand the wrapper before they can stop using it. 
This particular issue was a sore point for me using Pylons' SQLAlchemy 
config from the paster template.

Oddball example:

def create_special():
    return dbapi.connect('odd database')

import sqlalchemy
e = sqlalchemy.create_engine('oddball://database', creator=create_special)
pyramid_sqla.add_engine(engine=e)

I think you should just require *two* extra lines of boilerplate:

import sqlalchemy
e = sqlalchemy.engine_from_config(settings)
pyramid_sqla.add_engigne(engine=e)

Users can learn more SQLAlchemy and less pyramid_sqla, confident that 
add_engine is not doing any magic.


How do I configure a Session() that talks to more than one database? A 
SQLAlchemy session can have more than one bind: Session.configure(binds={
User:engine1, 
Account:engine2})(http://www.sqlalchemy.org/docs/orm/session.html#enabling-two-phase-commit).
 
SQLAlchemy will persist each class with its respective database engine.


I encourage you to test your code without _base.metadata.bind = x. Mine 
works fine without it, and it is easier to persist the same table to more 
than one database engine if the metadata is not bound.

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to pylons-discuss@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to