Guest User

Untitled

a guest
Jul 12th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. ###############################
  2. require "rubygems"
  3. require "sequel"
  4.  
  5. DB = Sequel.connect(
  6. :adapter=>'postgres',
  7. :host=>'localhost',
  8. :database=>'foo',
  9. :user=>'foo',
  10. :password=>'foo'
  11. )
  12.  
  13.  
  14. f = File.open("/tmp/foo.csv", "w")
  15. DB['select * from foo'].each do |row|
  16. i = ""
  17. i = i + row[:id] + ","
  18. i = i + row[:title] + "\n"
  19. f.write i
  20. end
  21. f.close
  22. ###############################
Add Comment
Please, Sign In to add comment