def companies_by_project_number(): try: cursor.execute(sql_1) results_1 = cursor.fetchall() cursor.execute(sql_2) results_2 = cursor.fetchall() dictionary = {} for row in results_2: if row[0] not in dictionary: dictionary.setdefault(row[0], []) dictionary[row[0]].append(row[1]) else: dictionary.setdefault(row[0], []).append(row[1]) for k, v in dictionary.items(): dictionary[k] = TextBox.avg_color(v) for i in results_1: if i[1] != 0: for k, v in dictionary.items(): if i[0] == k: Picture.add_to_textboxes(dictionary[k], 15*int(i[1]), k) Picture.drawer("companies_by_project_number.png") except Exception as e: print(e)
def project_name_by_status(): try: cursor.execute(sql_7) results_7 = cursor.fetchall() dictionary = {} for row in results_7: if row[0] not in dictionary and row[0] != None: dictionary.setdefault(row[0], []) dictionary[row[0]].append(row[1]) for k, v in dictionary.items(): dictionary[k] = TextBox.avg_color(v) for k, v in dictionary.items(): Picture.add_to_textboxes(v, 50, k) Picture.drawer("project_name_by_status.png") except Exception as e: print(e)