31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/free_zipcode_data/state_table.rb', line 31
def write(row)
return nil unless row[:short_state]
row[:state] = 'Marshall Islands' if row[:short_state] == 'MH' && row[:state].nil?
country_id = get_country_id(row[:country])
sql = " INSERT INTO states (abbr, name, country_id)\n VALUES ('\#{row[:short_state]}',\n '\#{escape_single_quotes(row[:state])}',\n \#{country_id}\n )\n SQL\n begin\n database.execute(sql)\n rescue SQLite3::ConstraintException\n # Swallow duplicates\n end\n\n update_progress\nend\n"
|