Sha256: 09c6c2ad54e71711a4312f2ed6213405655f486ba3e530c5fc44ad78167e68ae
Contents?: true
Size: 1.49 KB
Versions: 1
Compression:
Stored size: 1.49 KB
Contents
require_relative 'BaseAction.rb' #noinspection RubyResolve module PPCurses class InsertSQLDataAction < GetDataAction def initialize( actions, sql, db ) super(actions) @sql = sql @db = db end def win_height 8 + @actions.length end def after_actions prepared_sql = @sql data_array = [] @actions.each do |action| prepared_sql = prepared_sql.sub('?', action.data) data_array.push(action.data) end self.prompt_to_change_data(prepared_sql, data_array) end # # returns true if data was inserted # def prompt_to_change_data(user_display_sql, data_array) self.print_line(user_display_sql) proceed = GetBooleanAction.new('Proceed? ') proceed.set_parent_action(self) proceed.set_window(@win) proceed.execute() did_insert = false if proceed.data == '1' self.print_line('') begin prep_statement = @db.prepare(@sql) prep_statement.bind_params(data_array) prep_statement.execute() prep_statement.close() did_insert = true self.print_success_line('Execution successful') rescue SQLite3::Exception => e self.print_error_line('Exception occurred') self.print_error_line(e.message) ensure self.print_line('') self.print_line('< Press any key to continue > ') @win.getch() end end did_insert end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ppcurses-0.0.21 | lib/ppcurses/actions/InsertSQLDataAction.rb |