Пример #1
0
def main():
    print("1. Import Data")
    print("2. Search")
    print("3. Cancel")
    value = input("What would you like to do?\n")
    if value == '1':
        # Only allow fresh collection to import files.
        num_records = DatabaseHandler.count_number_records()
        if num_records == 0:
            files: List[str] = DATA_FILES.split(',')
            for file in files:
                DataImport.import_data(DATA_PATH + file)
        else:
            logger.error('Number of records in database is ' +
                         str(num_records) + '. Should be 0 to import files.')
    elif value == '2':
        pass
    elif value == '3':
        pass
    elif value == 'deletealldata':
        DatabaseHandler.delete_all_records()
        try:
            shutil.rmtree(PATH_IMG_DOWNLOAD)
            logger.info('Deleted path: ' + PATH_IMG_DOWNLOAD)
        except OSError as ose:
            logger.error(ose)
    pass
Пример #2
0
def main():
    if action == '-s':
        result = DatabaseHandler.execute_query({'name': arg})
        print(result)
    elif action == '-i':
        # Only allow fresh collection to import files.
        num_records = DatabaseHandler.count_number_records()
        if num_records == 0:
            files: List[str] = DATA_FILES.split(',')
            for file in files:
                DataImport.import_data(DATA_PATH + file)
        else:
            logger.error('Number of records in database is ' +
                         str(num_records) + '. Should be 0 to import files.')