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.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”

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

Appreciating your help.



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