Sha256: 51e8bd6fbdceaf9d5dac1ef2dbe627881dc09e56c27abf934d583503e1cf6fdc

Contents?: true

Size: 406 Bytes

Versions: 93

Compression:

Stored size: 406 Bytes

Contents

#!/usr/bin/env ruby

require 'pg'
require 'stringio'

# An example of how to stream data to your local host from the database as CSV.

$stderr.puts "Opening database connection ..."
conn = PG.connect( :dbname => 'test' )

$stderr.puts "Running COPY command ..."
buf = ''
conn.transaction do
	conn.exec( "COPY logs TO STDOUT WITH csv" )
	$stdout.puts( buf ) while buf = conn.get_copy_data
end

conn.finish

Version data entries

93 entries across 93 versions & 6 rubygems

Version Path
pg-0.17.0 sample/copyto.rb
pg-0.16.0-x86-mingw32 sample/copyto.rb
pg-0.16.0-x64-mingw32 sample/copyto.rb
pg-0.16.0 sample/copyto.rb
pg-0.15.1-x86-mingw32 sample/copyto.rb
pg-0.15.1-x64-mingw32 sample/copyto.rb
pg-0.15.1 sample/copyto.rb
pg-0.15.0-x86-mingw32 sample/copyto.rb
pg-0.15.0-x64-mingw32 sample/copyto.rb
pg-0.15.0 sample/copyto.rb
pg-0.15.0.pre.454-x64-mingw32 sample/copyto.rb
pg-0.15.0.pre.454-x86-mingw32 sample/copyto.rb
pg-0.15.0.pre.454 sample/copyto.rb
pg-0.15.0.pre.432-x86-mingw32 sample/copyto.rb
pg-0.15.0.pre.432 sample/copyto.rb
pg-0.14.1-x86-mingw32 sample/copyto.rb
pg-0.14.1 sample/copyto.rb
pg-0.14.1.pre.363-x86-mingw32 sample/copyto.rb
pg-0.14.1.pre.363 sample/copyto.rb
pg-0.14.0-x86-mingw32 sample/copyto.rb