if you are reflecting tables, and sorting them reveals that there are mutual 
dependent foreign keys (or some other kind of cycle), then the tables can’t be 
delivered in foreign key dependency order, there is no such ordering.

when creating Table objects you can break such a cycle using the use_alter 
flag: 
http://docs.sqlalchemy.org/en/rel_0_9/core/constraints.html?highlight=use_alter#creating-dropping-foreign-key-constraints-via-alter

you could set this flag for an existing set of reflected tables by iterating 
through each table.constraints.

if you’re just looking to drop all tables, its a good idea to drop all the 
constraints ahead of time, see 
http://www.sqlalchemy.org/trac/wiki/UsageRecipes/DropEverything




On Jan 31, 2014, at 5:04 AM, Nicola Palumbo <[email protected]> wrote:

> Hi All,
> 
> I would like to get all tables of a database that I have read only access.The 
> lines below raise "CircularDependencyError: Circular dependency detected. 
> Cycles:...."
> 
> How can I get around this problem? Any idea?
> 
> from sqlalchemy.schema import MetaData
> meta = MetaData()
> meta.reflect(bind=db_engine)
> tables = meta.sorted_tables
> 
> #tables = meta.tables
> for table in tables:
>     print table
> 
> 
> Thanks
> 
> Nicola
> 
> -- 
> 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/groups/opt_out.

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to