title: How do I create a .csv file with specific sqlite table fields using ruby and sequel gem?
body: <p>The bottom code is supposed to create a new test table, add data from two existing tables and add the contents to a new csv file. The parsing of both existing tables works fine, and the .csv also gets created without error. The issue I'm having is that the .csv is being created with blank data except for the 3 "Fixnum" header columns above. I've tried multiple different things including numerous variations of string interpolation.</p>
  
  <pre><code>require 'sequel'
  
  # Run time argv
  DB = Sequel.connect("sqlite://#{db_file}")
  
  # Load to_csv method via extension
  DB.extension(:sequel_3_dataset_methods)
  
  # Create test case
  DB.create_table(:"#{table}"){
  Fixnum :"News-1"
  Fixnum :"News-2"
  Fixnum :"Item-1"
  }
  
  # Parse news table
  DB['SELECT one, two FROM news WHERE Id=12;'].each do |news|
  #p news
  end
  
  # Parse item table
  DB['SELECT news_feed FROM item;'].each do |item|
  #p item
  end
  
  # Insert data into csv_file
  1.times{|i|
  DB[:"#{table}"].insert("#{news}", "#{news}", "#{item}")
  }
  
  # Open .csv file, write and save
  File.open("#{csv_file}", 'w'){|f|
  f &lt;&lt; DB[:"#{table}"].to_csv                        
  }
  </code></pre>