Recommendations for a PostgreSQL driver for Ruby that supports bytea types correctly?

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.

On 2/9/2010 10:30 AM, CyclingGuy wrote:

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.

Look at ruby-pg. http://bitbucket.org/ged/ruby-pg/overview/
(perhaps in concert with Sequel) http://sequel.rubyforge.org/

On 2/9/2010 10:43 AM, Reid T. wrote:

Look at ruby-pg. http://bitbucket.org/ged/ruby-pg/overview/
(perhaps in concert with Sequel) http://sequel.rubyforge.org/

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>

On 2010-02-09, Reid T. [email protected] wrote:

On 2/9/2010 10:30 AM, CyclingGuy wrote:

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.

Look at ruby-pg. http://bitbucket.org/ged/ruby-pg/overview/
(perhaps in concert with Sequel) http://sequel.rubyforge.org/

Perhaps more importantly:

The subject says “that supports bytea types correctly”. Should we infer
that you have found a PostgreSQL driver for Ruby that does NOT support
selecting and inserting bytea types? If so, which one? What were the
symptoms of its incorrect support?

-s

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs