def get_item_selected_row(tableView): """TableView 의 선택영역에 대한 item 값을 리스트로 전달한다. (선택된 전체의 데이터 전달, is not sorted) :param tableView: table widget object :return : list, [item1,item2, ...] """ bind_list = list() for idx in tableView.selectedIndexes(): LOG.debug(tableView.model().data(idx), idx.row(), idx.column(), idx.data()) bind_list.append(tableView.model().data(idx)) return bind_list
def __init__(self, user, passwd, dbname, host="localhost", port=3306, charset="utf8"): DBWrapper.__init__(self) try: log.debug(f"MySql connection info. ({host}:{user}/{passwd}@{dbname}") self.connector = MySQLdb.connect(host, user, passwd, dbname, port=port, charset=charset) except: log.exception() raise try: self.cursor = self.connector.cursor() except: log.exception() raise
def __init__(self, filename, auto_commit=None): DBWrapper.__init__(self) try: log.debug("Sqlite connection info. (%s)" % filename) # autoCommit : None | DEFERRED | IMMEDIATE | EXCLUSIVE self.connector = sqlite3.connect(filename, isolation_level=auto_commit) # self.connector = sqlite3.connect(filename) except: log.exception() raise try: self.cursor = self.connector.cursor() except: log.exception() raise
def get_items_selected_rows(tableView): """TableView 의 선택영역에 대한 item 값을 이중 리스트로 전달한다. :param tableView: table widget object :return : list, [[item1,item2,...], ... ] """ # TableView (model type) 에서 select 된 모든 row의 항목 가져오는 방법. (다중 선택 모드) bind_list = list() rows = tableView.selectionModel().selectedRows() model = tableView.model() LOG.debug(rows, model.columnCount()) for row in rows: items = list() for col in range(model.columnCount()): items.append(model.data(model.index(row.row(), col))) bind_list.append(items) return bind_list
def __del__(self): LOG.debug() self.close()