Reputation: 17246
If I have a simple join-based inheritance relationship in SQLAlchemy that I've replicated between schemas using "SET search_path", how can I access them simultaneously in order to do a copy between them?
I've looked at things like the entity name recipe and it's not quite clear how to do it in the case of an inheritance. I've also looked at select_from but it's not clear how the subclasses would load if with_polymorphic is spec'd on the parent class.
Ideally, what I would like to do is iterate over a version of my class tied to the public schema and generate copies of it as instances of the same class tied to the particular schema in question.
Upvotes: 1
Views: 260
Reputation: 17246
I ended up settling on using the search path to query instances from the public schema and then resetting the search path when creating new instances in the target schema. My concern about this approach is I have to evaluate this query and turn it into a list held in memory so that I can switch the search path and then create the child instances.
It would be nice to have two classes that are each mapped to the correct schema so you can iterate over the public schema class at the same time that you are creating the child instances.
Upvotes: 1