From: Grant Gray Date: 2009-07-01T05:36:34+09:00 Subject: Re: MySQL to SQlite data movement Grant Gray wrote: Hi Guys, I solved the problem. I did a few syntax changes to clean up the code but here it is: #!/usr/bin/env ruby require 'dbi' require 'rubygems' require 'sqlite3' require 'mysql' my1 = Mysql.real_connect("server", "username", "password", "cnms") my2 = SQLite3::Database.open( 'simo/db/development.sqlite3' ) my2.results_as_hash = true stmt = my2.prepare("insert into usages ( device_id, bytes_sourced ) values( ?, ? )" ) result = my1.query("SELECT device_id, bytes_sourced FROM odma_unit") result.each do |row| stmt.execute(row[0], row[1]) my1.close end The problem seemed to lay in the results_as_hash = true wrapper. "If you do this, then all rows will be returned as Hash objects, with the column names as the keys." Once it dawned on me that it was not getting the key right, the code I used worked. Thanks for the guidance again. I couldn't have done it without your help. Gigg -- Posted via http://www.ruby-forum.com/.