Ok, updated SQLAlchemy to version 0.9 and then had the issue found in this thread: https://groups.google.com/forum/#!searchin/sqlalchemy/binds/sqlalchemy/6AvZ4DYua78/Heo8GVlysJwJ
Following the linked example there resolved my issue. Thanks! On Wednesday, February 4, 2015 at 7:58:14 PM UTC-8, Michael Bayer wrote: > > > > Katie Wurman <[email protected] <javascript:>> wrote: > > > I’m trying to design an application that has several engines and unique > models associated with each engine. > > > > Ideally, I’d like to create one base/abstract model per engine, set the > bind for those, and have all child models inherit that bind. Unfortunately > I can’t seem to figure out how that would work. My best guess is the > following non-working solution: > > > > # in models.py: > > Base1 = declarative_base() > > Base2 = declarative_base() > > > > class User1(Base1): > > “”” > > Some model assigned to engine 1 > > “”” > > class User2(Base2) > > “”” > > Some model assigned to engine 2 > > “”” > > > > # in main.py: > > > > engine1 = create_engine("postgresql+psycopg2://URI1”) > > engine2 = create_engine("postgresql+psycopg2://URI2”) > > > > from .models import Base1, Base2 > > mybinds = { > > Base1 : engine1, > > Base2 : engine2 > > } > > > > db = scoped_session(sessionmaker()) > > db.configure(binds=mybinds) > > > > This results in the following error: > > sqlalchemy.orm.exc.UnmappedClassError: Class > 'sqlalchemy.ext.declarative.api.Base' is not mapped > > > > I’ve tried to use an abstract base as a key for mybinds with no luck, > however, when I use User1, User2, it works. I don’t want to do it like this > because I have a large number of models and would prefer not to list them > all out in the binds dictionary. > > > > How do I assign a bind to a model in this case? > > this kind of thing should be working in git master, grab it at > https://github.com/zzzeek/sqlalchemy and let me know if that doesn’t fix > it. > > > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
