The whole scheme seems risky to me. What if your program crashes after you've deleted everything from the database but before you've written to your spreadsheet? Everything will be lost. Better to copy the data then delete only the rows you've successfully written.
Without knowing what sort of data you're working with it's difficult to suggest any other options. But you could move your rows into a temporary table, or use an extra column as a flag (set the flag for all rows, then select * where flag == t, delete * where flag == t).
Also it may be worth reading up on sqlite transaction handling.