class PG::TextEncoder::CopyRow - pg-0.18.4 Documentation

# class PG::TextEncoder::CopyRow

This class encodes one row of arbitrary columns for transmission as COPY data in text format. See the COPY command for description of the format.

It is intended to be used in conjunction with PG::Connection#put_copy_data .

The columns are expected as Array of values. The single values are encoded as defined in the assigned type_map. If no type_map was assigned, all values are converted to strings by PG::TextEncoder::String.

Example with default type map ( TypeMapAllStrings ):

    conn.exec "create table my_table (a text,b int,c bool)"
    enco = PG::TextEncoder::CopyRow.new
    conn.copy_data "COPY my_table FROM STDIN", enco do
      conn.put_copy_data ["astring", 7, false]
      conn.put_copy_data ["string2", 42, true]
    end

This creates `my_table` and inserts two rows.