Maybe my brain's just not working, but I don't see how what you are proposing to do will help you with your goal. If you are looking to take data from a production database and archive it and then subsequently remove that data from the production data there is no need to convert to CSV. Database tables should have keys. Move the data from A->B and then cache all of the keys using DBM. Confirm all data was moved to B. If true, then go ahead and iterate through all of the keys and delete them from the production database. That's if you need to do this in Perl.

I wouldn't do this in Perl at all however. I would create a backup database or schema in my database and use SQL in a transaction to do this work.

create table foo; create table foo (id text, name varchar(15)); insert into foo values ('a','foo'); insert into foo values ('b','foo'); insert into foo values ('c','foo'); create table backupfoo (id text, name varchar(15)); insert into backupfoo (select * from foo); delete from foo; -- you would obviously use a WHERE clause to restrict + what you are deleting >>> 3 records copied
Now, you can just push everything from the backup table to an archive offline (example uses PostgreSQL).

pg_dump -d YOURDATABASE -t backupfoo > mybackup.sql

Then you can reload that data in a different database entirely.

psql -d YOURDATABASEARCHIVE -f mybackup.sql

You could script this or use a CPAN module to script this.

Celebrate Intellectual Diversity


In reply to Re: using the split command by InfiniteSilence
in thread using the split command by deano

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.