From: Mike Keller Date: 2007-01-11T05:11:38+09:00 Subject: Undefined Method `free' I've got a CSV file that I'm trying to read from and insert the values into a mySQL DB. However whenever I run the script I get the following error: csvadd.rb:27: undefined method `free' for nil:NilClass (NoMethodError) from csvadd.rb:12:in `with_db' from csvadd.rb:21 Here is the code I'm using: def with_db dbh = Mysql.real_connect('localhost','myuser','mypass','mydb') begin yield dbh rescue MysqlError => error puts "Error: #{error}" is nil ensure dbh.close end end with_db do |db| res = db.query('load data local infile \'/full/path/to/csvdoc.csv\' into table mytable fields teminated by \',\' lines teminated by \'\n\' ignore 1 lines') res.free end I've tried searching google, here, ruby docs, other forums, I felt I was safe asking the question after all that. However if I did miss something I apologize in advance. -- Posted via http://www.ruby-forum.com/.