On 09/02/2012 19:51, Michael Bayer wrote:
So, my plan is to have one engine per database I connect to.
But what to do about tables?
So what does it mean for your application to import a module, that has a class "MyClass",
which should be mapped to a table, but when the app is running, that table essentially doesn't
exist ? Does that render "MyClass" useless
Yes.
and if so why import it ?
Thing's like Pyramid config's scan (not the case here) and nose (one of
the issues here) mean that it should be importable but not cause
anything (including prepare) to blow up.
Otherwise, if it is still useful, and I'm guessing you're using the declared
reflection recipe,
What on earth would give you that idea? ;-) (yes, yes I am...)
you'd need to enhance the usage of prepare() such that the class is not
actually mapped, since there is no table.
Yeah, I had this working with the Table call wrapped in a try/except.
Check this post, read the section "Model Setup":
http://techspot.zzzeek.org/2012/01/11/django-style-database-routers-in-sqlalchemy/
Almost, but...
We can't have per-connection models, that would be semantically weird.
Using a different metadata at session creation time, keyed off the dsn
of the database connected to, and with irrelevant classes blowing up if
used but ignored otherwise is semantically what I'm after. Clues as to
how to implement gratefully received...
Chris
--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.