How to Sqlite-to-CSV via Sequel?

Hey folks,

I want to produce a CSV file from an object that is the result (table or
relation) of a SQL query in Sequel. I simply want to produce a CSV
output as file.

It starts like this


    require "sequel"

    DB = Sequel.sqlite("name.sqlite")

    x = DB["SELECT A1.id, A1.title,
      A1.time as start,
      A2.time as end,
      (A2.time - A1.time) as duration
      FROM name A1, name A2
      WHERE A1.title == A2.title
      AND A1.status > A2.status;"]

Then, the Sequel docs mention a #to_csv “extension”

http://sequel.jeremyevans.net/rdoc-plugins/classes/Sequel/Sequel3DatasetMethods.html#method-i-to_csv

But I don’t know how to get this loaded and working.

Appreciating your help.
JJ

Nope,

DB.extension(:sequel_3_dataset_methods)

doesn’t the trick. However, Stackexchange writers provide a solution
that works.

Thanks.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs