Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
module Ruport::Format class SQL < Plugin attr_accessor :dbh def build_table_body src = Ruport::Config.source(:default) @dbh = DBI.connect(src.dsn, src.user, src.password) data.each do |r| output << "insert into #{@options.table_name} " output << "(#{@data.column_names.join(',')}) " output << "values (#{build_sql_values(r)});\n" end dbh.disconnect end def build_sql_values(row) row.map {|v| @dbh.quote(v) }.join(',') end def method_missing(message, *args) @options.send(message, *args) end Ruport::Renderer::Table.add_format self, :sql end end
This paste will be private.
From the Design Piracy series on my blog: