More information about the Underscore mailing list

[_] A question of elegance

Richard Price richardprice at gmail.com
Thu Mar 8 17:36:05 GMT 2007

On 08/03/07, s'unya <sunya.dickman at gmail.com> wrote:
> Hi,

>
> MY (not great) SOLUTION:
> 1) Create a csv from the data in the database and output it for an
> administrator so that they can simply copy and paste a csv as their means of
> update.
> 2) When changes are saved, data in the database table is Deleted and new csv
> file is parsed into separate values and insert all into the database. I
> toyed with UPDATE-ng the table until I ran out of records and then
> INSERT-ing extra records, but that seemed to be adding a heck of a lot of
> processing, so I am just DELETE-ing and INSERT-ing all data. As you can see
> a little cringe-worthy
>
> SO:
> What do you think I would be better off doing?


Maybe do what we do?

Have two identical tables:

table
table_import

import *all* of the spreadsheet into table_import, then delete table
and rename table_import to table, then recreate table_import.  Voila -
an updated table with minimal fuss.

We do this with massive datasets several times a day, which have large
number of changes each hour with no problems.  Its easier to import
the entire dataset en masse than it is to work out whta needs
updating.

Richard