Re: [sqlalchemy] How can copy tables with only the data inside and without the foreign keys, constraints and relations, from a DB to another DB?

2014-10-10 Thread Michael Bayer
though really, all you need to do is process your tables in dependency order, assuming you have no self-referential foreign keys. if you iterate through tables as follows: for table in metadata.sorted_tables: you'd be moving the data in order of dependency. http://docs.sqlalchemy.org/en/r

Re: [sqlalchemy] How can copy tables with only the data inside and without the foreign keys, constraints and relations, from a DB to another DB?

2014-10-10 Thread Michael Bayer
Assuming you're working with Oracle as is implied by your script, constraints can be disabled as in: http://www.dba-oracle.com/t_enabling_disabling_constraints.htm that is, for each table, issue a "DISABLE CONSTRAINT" for each FK constraint (using connection.execute("ALTER TABLE foo DISABLE CON

Re: [sqlalchemy] How can copy tables with only the data inside and without the foreign keys, constraints and relations, from a DB to another DB?

2014-10-10 Thread Eren Gölge
Here for example the code I use to transfer a table from my src DB to dst DB #!/usr/bin/env python import getopt import sys from sqlalchemy import create_engine, MetaData, Table from sqlalchemy.orm import sessionmaker from sqlalchemy.ext.declarative import declarative_base #from joblib import Pa

Re: [sqlalchemy] How can copy tables with only the data inside and without the foreign keys, constraints and relations, from a DB to another DB?

2014-10-10 Thread Michael Bayer
On Oct 10, 2014, at 10:30 AM, Eren Gölge wrote: > I try to do basic ETL job with SQLalchemy but it always enforces relations > between tables. SQLAlchemy doesn't do anything like that. I think you are referring to the FOREIGN KEY constraints that are within your database. > I only like to

[sqlalchemy] How can copy tables with only the data inside and without the foreign keys, constraints and relations, from a DB to another DB?

2014-10-10 Thread Eren Gölge
I try to do basic ETL job with SQLalchemy but it always enforces relations between tables. I only like to copy the tables with the raw data inside without the considration of table relations. How can I drop all those relations from the DB metadata and copy the tables. In addition I also need to