From: ts Date: 2002-11-19T16:44:57+09:00 Subject: Re: [DBI] How to write BLOBs in a Postgres DB? >>>>> "S" == Stefan Scholl writes: S> Are there any (working) examples of writing a BLOB into a S> Postgres db via DBI? pigeon% cat b.rb #!/usr/bin/ruby require 'dbi' DBI.connect('dbi:Pg:dbname=test', 'ts', '') do |dbd| dbd.do("drop table blob_test") rescue true dbd.do("create table blob_test (name VARCHAR(30), data OID)") data = File.readlines("cor1.jpg", nil)[0] puts "size : #{data.size}" dbd.do("insert into blob_test (name, data) VALUES (?,?)", "test", DBI::Binary.new(data)) dbd.select_all("select name, data from blob_test") do |name, res| if dbd.func(:blob_read, res) == data puts "ok" end end end pigeon% pigeon% b.rb size : 4402656 ok pigeon% Guy Decoux