Recommendations for a PostgreSQL driver for Ruby that supports byteatypes correctly?

C

CyclingGuy

Can anyone recommend a PostgreSQL driver for Ruby that supports
selecting and inserting bytea types?
I'm not looking to write server functions in Ruby, just client
applications.

Thank you
Eric.
 
R

Reid Thompson

quick test

$ irb
irb(main):001:0> require 'sequel'
=> true
irb(main):003:0> DB = Sequel.connect('postgres://[email protected]:5432/test')
=> #<Sequel::postgres::Database: "postgres://[email protected]:5432/test">
irb(main):006:0> DB.create_table :items do
irb(main):007:1* primary_key :id
irb(main):008:1> String :name
irb(main):009:1> Float :price
irb(main):010:1> Bytea :mybinary
irb(main):011:1> end
=> []
irb(main):013:0> items = DB[:items]
=> #<Sequel::postgres::Dataset: "SELECT * FROM \"items\"">
irb(main):017:0> items.insert :)name => 'test', :price => rand * 100, :mybinary
=> 'djf dfjdslkf fkfhsakfhwe sdaf hdfkhadsf jfasdfj m ^N ^M ')
(irb):17: warning: don't put space before argument parentheses
=> 1
irb(main):022:0> ds = DB[:items]
=> #<Sequel::postgres::Dataset: "SELECT * FROM \"items\"">
irb(main):023:0> ds.each do |row|
irb(main):024:1* p row
irb(main):025:1> end
{:mybinary=>"djf dfjdslkf fkfhsakfhwe sdaf hdfkhadsf jfasdfj m \016 \r ", :pric
e=>45.9518099286502, :name=>"test", :id=>1}
=> #<Sequel::postgres::Dataset: "SELECT * FROM \"items\"">
irb(main):026:0>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top