Hello Monks,

I have very little experience with Perl, and I am also new to this forum. I would greatly appreciate any direct or indirect help with a problem I am currently facing.

My program has several arrays which I intend to push into a pgSQL database. Each array represents a unique table in the database. I have used flat files as a medium for transport in the past, however the scale of data in this project requires more efficiency. After some research I have settled on using the COPY method of moving the data into the db.

So far, I have been able to find very few example of code using the pg_putcopydata method and those I have found I either do not understand or do not use a data structure much like the one I am using (arrays).

Each element in the array @ArrayInMemory will be a row in the db table with multiple columns delimited by /. This is what I image the code will be like:

@ArrayInMemory $dbh->do("COPY mytable(col1, col2, col3) FROM STDIN WITH DELIMITER '/' +"); foreach $row (@ArrayInMemory) { $dbh->pg_putcopydata($row); } $dbh->pg_putcopyend();

Again, thanks for any input on this topic and I hope we can generate a few quality examples for other users who are unfamiliar with the pg_putcopydata database handle method.


In reply to DBD:Pg pg_putcopydata by LiquidT

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.