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
jruby-pg-0.1-java sample/copyto.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/pg-0.20.0/sample/copyto.rb
pg-0.20.0-x86-mingw32 sample/copyto.rb
pg-0.20.0-x64-mingw32 sample/copyto.rb
pg-0.20.0 sample/copyto.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/copyto.rb
pg-0.19.1.pre20170124220800-x64-mingw32 sample/copyto.rb
pg-0.19.1.pre20170124220800-x86-mingw32 sample/copyto.rb
pg-0.19.1.pre20170124220800 sample/copyto.rb
pg-0.19.1.pre20170115074000-x64-mingw32 sample/copyto.rb
pg-0.19.1.pre20170115074000-x86-mingw32 sample/copyto.rb
pg-0.19.1.pre20170115074000 sample/copyto.rb
pg-0.19.0.pre20170115074000 sample/copyto.rb
pg-0.19.0-x86-mingw32 sample/copyto.rb
pg-0.19.0-x64-mingw32 sample/copyto.rb
pg-0.19.0 sample/copyto.rb
pg-0.19.0.pre20160904200247-x86-mingw32 sample/copyto.rb
pg-0.19.0.pre20160904200247-x64-mingw32 sample/copyto.rb
pg-0.19.0.pre20160904200247 sample/copyto.rb
pg-0.19.0.pre20160820113039-x86-mingw32 sample/copyto.rb