I the order is required for Foreign Key relationships. i.e. to make
sure the children are deleted before the parents.

So the "for table in reversed(meta.sorted_tables)" example is the more
correct way to delete all data.



On Feb 15, 1:29 pm, Arve Knudsen <arve.knud...@gmail.com> wrote:
> Thank you GHZ, it did work! Wondering about one thing though; the recipe in
> the documentation iterates over the tables in reverse sorted order, like so:
>
> for table in reversed(meta.sorted_tables)
>
> Do you know what this would be good for (since your code does not care about
> the table order)?
>
> Arve
>
>
>
>
>
>
>
> On Mon, Feb 14, 2011 at 2:51 PM, GHZ <geraint.willi...@gmail.com> wrote:
> > maybe it needs to be in a transaction:
>
> > con = engine.connect()
>
> > trans = con.begin()
>
> > for name, table in meta.tables.items():
>
> >    print table.delete()
> >    con.execute(table.delete())
>
> > trans.commit()
>
> > On Feb 14, 1:29 pm, Arve Knudsen <arve.knud...@gmail.com> wrote:
> > > Hi
>
> > > What's the right way to clear a database all of content, but keep the
> > > schema? I tried the method of deleting all tables athttp://
> >www.sqlalchemy.org/docs/05/metadata.html#reflecting-all-tables...,
> > > but content still remains. I couldn't find any documentation on
> > Table.delete
> > > either, for that matter. Maybe I'm missing something...
>
> > > Thanks,
> > > Arve
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "sqlalchemy" group.
> > 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.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
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