in reply to Quickest way to insert many rows with DBI

Postgres supports the copy command, though I'm not sure how to use it via DBI:
Command: COPY Description: Copies data between files and tables Syntax: COPY [ BINARY ] table [ WITH OIDS ] FROM { 'filename' | stdin } [ [USING] DELIMITERS 'delimiter' ] [ WITH NULL AS 'null string' ] COPY [ BINARY ] table [ WITH OIDS ] TO { 'filename' | stdout } [ [USING] DELIMITERS 'delimiter' ] [ WITH NULL AS 'null string' ]


holli, /regexed monk/

Replies are listed 'Best First'.
Re^2: Quickest way to insert many rows with DBI
by Anonymous Monk on Apr 11, 2006 at 09:51 UTC
    Are you suggesting I write out the data to a flat file first, then use the copy command to populate the table?

      I think that's what holli has in mind. You could use a piped open (or open2 or open3) to write to your copy command's stdin.

      Update: Looks like borisz has a better idea with DBD::Pg's COPY support.

      --

      Oh Lord, won’t you burn me a Knoppix CD ?
      My friends all rate Windows, I must disagree.
      Your powers of persuasion will set them all free,
      So oh Lord, won’t you burn me a Knoppix CD ?
      (Missquoting Janis Joplin)