def _customize_column_values(self, cols, col_vals, sample): col_map = {} for col in cols: col_map[col['COLNAME']] = col self.completer.update(col_map.keys()) col_name = get_input('Please enter column name: ') while col_name: if col_name not in col_map: print 'column %s is not a general column.' % col_name continue val = self._get_column_value('general', col_map[col_name], sample) col_vals[col_name] = val LOG.debug('Use customized value %s for column %s.', val, col_name) col_name = get_input('Please enter column name: ')
def _get_column_value(self, cat, col, sample): col_name = col['COLNAME'] col_type = col['TYPENAME'] print u'%s column %s: %s, type: %s, length: %s, default: %s, sample: %s' % \ (cat, col['COLNO'], col_name, col_type, col['LENGTH'], col['DEFAULT'], sample[col_name]) val = get_input("Please input column value: ") if val == '': val = sample[col_name] elif val.upper() == 'NONE': val = None elif col_type == 'TIMESTAMP': val = strptime(val, DATE_FORMAT) return val