Is the DropEverything recipe still the best way to drop everything via 
SQLAlchemy?

http://www.sqlalchemy.org/trac/wiki/UsageRecipes/DropEverything

The recipe is ancient (almost a year old! :) ) and I just want to check if 
there is a better way now.

How I got here (for searchability)...

When doing unit testing on a primarily PostgreSQL application I routinely 
drop all tables in a database with this:

def DropAllTables(EngineURL):
    import sqlalchemy
    engine = sqlalchemy.create_engine(EngineURL)
    meta = sqlalchemy.MetaData(engine)
    meta.reflect()
    meta.drop_all()

However, I've recently added tables that refer to each other (which required 
using "use_alter" on the ForeignKey definition to avoid problems) and 
drop_all ends up raising a CircularDependencyError.  In trying to resolve 
this I found these useful links, which ultimately led me to the 
DropEverything recipe:

http://www.luckydonkey.com/2007/11/23/postgresql-sqlalchemy-dropping-all-tables-and-sequences/
http://blog.pythonisito.com/2008/01/cascading-drop-table-with-sqlalchemy.html
http://www.sqlalchemy.org/trac/wiki/UsageRecipes/DropEverything

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/WnMxxvWM2IgJ.
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.

Reply via email to