def get_cell_cnt(db_config, table): db = ArkDBMySQL(db_config_file=db_config) query = f'SELECT COUNT(*) AS CNT FROM {table} WHERE CELL_PMOS_CNT+CELL_NMOS_CNT=%s' ret = dict() for i in range(1, 6): ret[i] = db.get_query_value('CNT', query, [i]) return ret
def update_bsf_uni_for_table(bsf_col, db_config_file, target_lib, start, cnt, force=False): db = ArkDBMySQL(db_config_file=db_config_file) if not force: unset_entry_cnt = db.get_query_value('CNT', f'SELECT COUNT(*) AS CNT FROM {target_lib} ' f'WHERE {bsf_col}_UNIFIED is null') if unset_entry_cnt == 0: print(f'{bsf_col}_UNIFIED column is set for all entries, skipping...') return # TODO: add fast mode, in which only null entries are selected and updated query = f'SELECT * FROM BSF_LIB LIMIT {start},{cnt}' uni_bsf_arr = db.run_query_get_all_row(query) runner_idx = start // cnt for row in tqdm(uni_bsf_arr, desc=f'Update {bsf_col}_UNI[{runner_idx:02}]'): db.run_sql_nocommit(f'UPDATE {target_lib} SET {bsf_col}_UNIFIED = %s WHERE {bsf_col} = %s', [row['BSF_UNI'].decode("utf-8"), row['BSF'].decode("utf-8")]) db.commit()
def prepare(db_config, query, n_jobs): db = ArkDBMySQL(db_config_file=db_config) item_cnt = db.get_query_value('CNT', query) return gen_limits(item_cnt, n_jobs)