[storm] Truncating a table

Jamu Kakar jkakar at kakar.ca
Tue Dec 9 17:40:04 GMT 2008


Hi,

On Mon, Dec 8, 2008 at 9:12 PM, Paul Hummer <paul.hummer at canonical.com> wrote:
> I have a need to basically clear out all the records from a table.  I could
> probably use store.execute, but the reason I'm using an ORM in the first place
> is to avoid writing SQL.  So I have the following code:

Storm was never designed with the assumption that you'd *never* have
to write SQL.  It makes it so that you mostly don't have to.  I
would use store.execute in this situation, mostly for performance
reasons.  The example code you've provided will perform very poorly
when you have a lot of rows to delete.

>        result = self._store.find(FooBarBaz)
>        self._store.rollback()

Note that using the result after rolling back the store is a bad
idea and probably won't work.  I would do this:

store.rollback()
store.execute("DELETE FROM foo")
store.commit()

Hope this helps,
J.



More information about the storm mailing list