Class: PG::TextDecoder::CopyRow

Inherits:
CopyDecoder show all
Defined in:
ext/pg_copy_coder.c

Overview

This class decodes one row of arbitrary columns received 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#get_copy_data .

The columns are retrieved as Array of values. The single values are decoded as defined in the assigned #type_map. If no type_map was assigned, all values are converted to strings by PG::TextDecoder::String.

Example with default type map ( TypeMapAllStrings ):

deco = PG::TextDecoder::CopyRow.new
conn.copy_data "COPY my_table TO STDOUT", deco do
  while row=conn.get_copy_data
    p row
  end
end

This prints all rows of my_table to stdout:

["astring", "7", "f"]
["string2", "42", "t"]

Instance Attribute Summary

Attributes inherited from Coder

#name

Method Summary

Methods inherited from CopyCoder

#delimiter, #delimiter=, #null_string, #null_string=, #to_h, #type_map, #type_map=

Methods inherited from Coder

#==, #decode, #dup, #encode, #format, #format=, #initialize, #inspect, #marshal_dump, #marshal_load, #oid, #oid=, #to_h

Constructor Details

This class inherits a constructor from PG::Coder