Unitialized local variable using fastercsv with sqlite3

I want to import data into an sqlite3 db, but am fuzzy as to how to
declare variables to get that done.

For:

:name => name

Both of the above need to be initialized or defined somehow, but I don’t
know how.

[email protected] ~/goodfellow-tool/db $
[email protected] ~/goodfellow-tool/db $ ruby import.rb
[“one”]
import.rb:11: undefined local variable or method name' for main:Object (NameError) from /usr/lib/ruby/gems/1.8/gems/fastercsv-1.2.3/lib/ faster_csv.rb:1458:ineach’
from /usr/lib/ruby/gems/1.8/gems/fastercsv-1.2.3/lib/
faster_csv.rb:1003:in foreach' from /usr/lib/ruby/gems/1.8/gems/fastercsv-1.2.3/lib/ faster_csv.rb:1175:inopen’
from /usr/lib/ruby/gems/1.8/gems/fastercsv-1.2.3/lib/
faster_csv.rb:1002:in `foreach’
from import.rb:8
[email protected] ~/goodfellow-tool/db $
[email protected] ~/goodfellow-tool/db $ cat import.rb
require ‘rubygems’
require ‘fastercsv’
require ‘/home/thufir/goodfellow-tool/config/environment.rb’

infile = “data.csv”

FCSV.foreach(infile) do |row|
p row
Call.new(
:name => name
)
end
[email protected] ~/goodfellow-tool/db $
[email protected] ~/goodfellow-tool/db $ sqlite3 development.sqlite3
SQLite version 3.4.1
Enter “.help” for instructions
sqlite> .schema
CREATE TABLE calls (“id” INTEGER PRIMARY KEY NOT NULL, “name” varchar
(255) DEFAULT NULL);
CREATE TABLE schema_info (version integer);
sqlite>
sqlite> SELECT * FROM calls;
1|zero
sqlite> .quit
[email protected] ~/goodfellow-tool/db $
[email protected] ~/goodfellow-tool/db $ cat data.csv
“one”
“two”
“three”
[email protected] ~/goodfellow-tool/db $

thanks,

Thufir

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