def check_uniqeid_exist(uniqeid): uniqeid = uniqeid.upper() if FileOperator.csv_or_db() == "db": server_name, user_name, user_password, database_name = FileOperator.app_config_reader( ) db = sql.connect(host=server_name, user=user_name, password=user_password, charset='utf8', use_unicode=True, autocommit=True) cursor = db.cursor() query_in_users_exist = "SELECT unique_identifier FROM BloodDonationStorage.Donor WHERE unique_identifier = '" + uniqeid + "';" cursor.execute(query_in_users_exist) allusers = cursor.fetchall() if allusers: print("Already in the database.") return False else: return True else: file = open("Data/donors.csv", "r", encoding="utf-8") reader = csv.reader(file) for line in reader: if len(line) != 0 and uniqeid == line[6].upper(): print("Already in the database.") file.close() return False file.close() return True
def search_in_file(which_file): search_term = input("Search term: ") print("-" * 52) if FileOperator.csv_or_db() == 'db': Search.search_in_file_db(which_file, search_term) else: Search.search_in_file_csv(which_file, search_term)
def listing_database(which_file): if FileOperator.csv_or_db() == 'db': ListingDataBase.listing_database_db(which_file) else: ListingDataBase.listing_database_csv(which_file)
def search_in_ids(id): if FileOperator.csv_or_db() == 'db': ChangeClass.search_in_ids_db(id) else: ChangeClass.search_in_ids_csv(id)