csv2sql – convert comma-separated-values file to sql
It was initially written by Mirek Rusin <email@example.com>
I just ported it to ruby 1.9.X, I added rspec cases and yard support
Csv2sql class goes deeper into conversion process of csv files, ie:
puts Csv2sql.new("test.csv").to_inserts(:bulk => true)
start tramsaction; insert into test_csv values (1, "test 1"), (2, "test 2"), (3, "test 3"), (4, "test 4"); commit;
puts Csv2sql.new("account_balances.csv").to_updates([nil, 'balance'], :table => 'accounts')
start transaction; update accounts set balance = "0" where id = "0345S"; update accounts set balance = "3301.37" where id = "0252S"; update accounts set balance = "11903.33" where id = "0345G"; update accounts set balance = "47028.32" where id = "0324G"; ... commit;
You can use optional arguments, ie:
:bulk - to get bulk inserts
:before :after :row_filter ...
For more details see api docs.
Contributing to csv2sql
Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
Fork the project
Start a feature/bugfix branch
Commit and push until you are happy with your contribution
Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
Copyright © 2011 Victor Pereira. See LICENSE.txt for further details.