Sha256: f58e3c935a9d41e374052f00432eee977e07fef4cc4ffe82c1e807f8b9282db9
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
require_relative 'BaseAction.rb' module PPCurses class InsertSQLDataAction < GetDataAction def initialize( actions, sql, db ) super(actions) @sql = sql @db = db end def winHeight() 8 + @actions.length end def afterActions() preparedSql = @sql dataArray = [] @actions.each do |action| preparedSql = preparedSql.sub('?', action.data) dataArray.push(action.data) end self.promptToChangeData(preparedSql, dataArray) end def promptToChangeData(userDisplaySQL, dataArray) self.printLine(userDisplaySQL) proceed = GetBooleanAction.new('Proceed? ') proceed.setParentAction(self) proceed.setWindow(@win) proceed.execute() if proceed.data == '1' then self.printLine('') begin prepStatement = db.prepare(sql) prepStatement.bind_params(dataArray) prepStatement.execute() prepStatement.close() self.printSuccessLine('Execution successful') rescue SQLite3::Exception => e self.printErrorLine('Exception occurred') self.printErrorLine(e.message) ensure self.printLine('') self.printLine('< Press any key to continue > ') @win.getch() end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ppcurses-0.0.19 | lib/ppcurses/actions/InsertSQLDataAction.rb |