Hi, 

Is it possible to reflect from one engine and then use some of the tables 
reflected as base to create tables in a second, different engine?

A possible way:

A_engine = create_engine("postgresql+psycopg2://...A...)
B_engine = create_engine("postgresql+psycopg2://...B...)

A_metadata = MetaData(schema='A', bind=A_engine)
B_metadata = MetaData(schema='B', bind=B_engine)

A_metadata.reflect(bind=A_engine)
A_table = A_metadata.tables['A_table']

A_table.metadata = B_metadata   
A_table.schema = 'B'

But now, I'm not sure how to tell A_metadata that it has a A_table to care 
for.

I've tried also with similar success using the 'autoload' and with the 
'automap_base',  instead of reflect.

Any ideas? is this too hacky/crazy/stupid? If not, it is a better way I 
haven't found? 

The use case is that I'd like to reflect what are the tables from 
production database, and use them as 'templates' to create a new database 
for testing.
That is, I want to be able to create in my test database with the actual 
reflection of what it is in production, and use SQLAlchemy to control the 
creation of fake data in it.

Thanks in advance!

Luis


-- 
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 http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to