Sha256: f5dddc624b44b4340f8ffefaff760a7ad98745da3407079f0f36cdd8769ccea9
Contents?: true
Size: 799 Bytes
Versions: 6
Compression:
Stored size: 799 Bytes
Contents
module RailsDb class SqlController < RailsDb::ApplicationController def index load_query end def execute load_query render :index end def csv load_query send_data(@sql_query.to_csv, type: 'text/csv; charset=utf-8; header=present', filename: 'results.csv') end def import end def import_start @importer = SqlImport.new(params[:file]) result = @importer.import if result.ok? flash[:notice] = 'File was successfully imported' else flash[:alert] = "Error occurred during import: #{result.error.message}" end render :import end private def load_query @sql = "#{params[:sql]}".strip @sql_query = RailsDb::SqlQuery.new(@sql).execute end end end
Version data entries
6 entries across 6 versions & 1 rubygems