Sha256: 4c84842233af785d090f01b89f3ea4a7c08e45f73e9c39fba87bc3ab3c985566
Contents?: true
Size: 848 Bytes
Versions: 3
Compression:
Stored size: 848 Bytes
Contents
# -*- ruby -*- require 'yugabyte_ysql' require 'stringio' # Using COPY asynchronously $stderr.puts "Opening database connection ..." conn = YugabyteYSQL.connect(:dbname => 'test' ) conn.setnonblocking( true ) socket = conn.socket_io $stderr.puts "Running COPY command ..." buf = '' conn.transaction do conn.send_query( "COPY logs TO STDOUT WITH csv" ) buf = nil # #get_copy_data returns a row if there's a whole one to return, false # if there isn't one but the COPY is still running, or nil when it's # finished. begin $stderr.puts "COPY loop" conn.consume_input while conn.is_busy $stderr.puts " ready loop" select( [socket], nil, nil, 5.0 ) or raise "Timeout (5s) waiting for query response." conn.consume_input end buf = conn.get_copy_data $stdout.puts( buf ) if buf end until buf.nil? end conn.finish
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
yugabyte_ysql-0.3 | sample/async_copyto.rb |
yugabyte_ysql-0.2 | sample/async_copyto.rb |
yugabyte_ysql-0.1 | sample/async_copyto.rb |