Im trying to insert into the database but sinatra throws this error
DataObjects::ConnectionError at / database is locked
at line Name.create(babyname: name ,year1900: results[0] ,year1910: results[1] ,year1920: results[2] ,year1930: results[3],year1940: results[4],year1950: results[5] ,year1960: results[6],year1970: results[7] ,year1980: results[8] ,year1990: results[9] ,year2000: results[10])
This is how im reading the text file and creating the name
File.open("names-data.txt", "r") do |f|
f.each_line do |line|
item = line.split(/\n/)
array = item[0].split(/\s+/)
name = array[0]
array.shift
pop = array
results = pop.map { |number| if number =~ /0/ then 1001 else number.to_i end }
Name.create(babyname: name ,year1900: results[0] ,year1910: results[1] ,year1920: results[2] ,year1930: results[3],year1940: results[4],year1950: results[5] ,year1960: results[6],year1970: results[7] ,year1980: results[8] ,year1990: results[9] ,year2000: results[10])
end
end
Here are a few lines in the text file that i am reading
Abbigail 0 0 0 0 0 0 0 0 0 953 562
Abby 0 0 0 0 0 906 782 548 233 211 209
Abdiel 0 0 0 0 0 0 0 0 0 925 721
There are over 4000 lines