Re: [sqlalchemy] Re: The right way to clear database of content?

2011-02-15 Thread Arve Knudsen
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

[sqlalchemy] Re: The right way to clear database of content?

2011-02-15 Thread GHZ
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

Re: [sqlalchemy] Re: The right way to clear database of content?

2011-02-15 Thread Arve Knudsen
Aha, thanks again! :) Arve On Tue, Feb 15, 2011 at 1:55 PM, GHZ geraint.willi...@gmail.com wrote: 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

[sqlalchemy] Re: The right way to clear database of content?

2011-02-14 Thread GHZ
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

RE: [sqlalchemy] Re: The right way to clear database of content?

2011-02-14 Thread Arve Knudsen
Thanks, will give this a shot. Sent from my Windows Phone From: GHZ Sent: 14. februar 2011 14:51 To: sqlalchemy Subject: [sqlalchemy] Re: The right way to clear database of content? maybe it needs to be in a transaction: con = engine.connect() trans = con.begin() for name, table in