Currently, I'm instantiating a new engine and declarative automap base for each MySQL database I'd like to include in my session and then individually mapping reflected tables to the relevant engines. Some sample code to clarify:
report_engine = create_engine(URL(drivername='mysql', host='prod-mysql-analytics-master.box', port='3306', query={'read_default_file':'/srv/db.cnf'}, database='report')) report_base = automap_base() report_base.prepare(report_engine, reflect=True) md_engine = create_engine(URL(drivername='mysql', host='prod-mysql-analytics-master.box', port='3306', query={'read_default_file':'/srv/db.cnf'}, database='md')) md_base = automap_base() md_base.prepare(md_engine, reflect=True) # map tables to classes user_practice_contacts = md_base.classes.user_practice_contacts user_professional_details = md_base.classes.user_professional_details users = report_base.classes.users cities = report_base.classes.cities sess = scoped_session(sessionmaker(twophase=True, binds={user_practice_contacts:md_engine, user_professional_details:md_engine, users:report_engine, cities:report_engine})) This seems like a hack-ish approach so I'm wondering if there's a better way. Must a separate engine and base be created for each MySQL DB? Each DB resides on the same MySQL instance with the same host name. And must each table be explicitly bound in the session creation? Still learning the ropes of SQLAlchemy so forgive me if these are obvious questions. Thanks for your time! -- 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 https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.