Jochen Kaechelin wrote: > How can I read a localy stored file and insert it into a mysal blob > field? > require 'mysql' begin dbh = Mysql.real_connect('localhost', 'username', 'passwd', 'database') data = File.read('data.txt') #get the data out of the file data = dbh.escape_string(data) #escape any quotes in the data dbh.query(" INSERT INTO table_name (char_field, int_field, tinyblob_field) VALUES ('apple', 3, '#{data}') ") result = dbh.query("SELECT * FROM table_name") while row = result.fetch_row do printf "%s, %s, %s\n", row[0], row[1], row[2] end result.free rescue Mysql::Error => e puts "Error code: #{e.errno}" puts "Error message: #{e.error}" puts "Error SQLSTATE: #{e.sqlstate}" if e.respond_to?('sqlstate') ensure dbh.close if dbh end -- Posted via http://www.ruby-forum.com/.