Last active
July 25, 2016 01:18
-
-
Save lkfken/a18e388a9c007a71e082cac328dab3b6 to your computer and use it in GitHub Desktop.
Convert CSV to Sqlite records.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sequel' | |
require 'csv' | |
csv_records = CSV.read('records.csv') | |
DB = Sequel.connect('jdbc:sqlite::memory:') | |
DB.create_table(:records) do | |
Integer :id, :primary_key => true | |
String :member_id, :null => false | |
String :lob, :null => false | |
String :region, :null => false | |
Date :region_eff, :null => false #Sequel.string_to_date('2010-09-10') # Date.civil(2010, 09, 10) | |
String :pcp, :null => false | |
Date :pcp_eff, :null => false #Sequel.string_to_date('2010-09-10') # Date.civil(2010, 09, 10) | |
end | |
DB[:records].import([:member_id, :lob, :region, :region_eff, :pcp, :pcp_eff], csv_records) | |
p DB[:records].all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment