Exemple #1
0
def main():
    print('Welcome to PersonDB!\n')
    log = True
    logged = False
    while log:
        prompt = input(
            'Type LOGIN to log in, CREATE to create a new user or EXIT to quit the program: '
        ).lower()
        if prompt == 'login':
            try:
                logged = login.login()
                if logged:
                    log = False
            except Exception as e:
                error_report(e)

        elif prompt == 'create':
            try:
                login.create()
            except Exception as e:
                error_report(e)

        elif prompt == 'exit':
            log = False

        else:
            print('Wrong input.')

    if logged:
        run = True
        while run:
            print('Type CREATE to create a new entry\n' +
                  'Type READ to search the database\n' +
                  'Type UPDATE to update a entry\n' +
                  'Type DELETE to remove a entry\n' +
                  'Type EXPORT to export the db to a csv file\n' +
                  'Type EXIT to exit')

            command = input("Command: ").lower()
            print('\n')

            if command == 'create':
                try:
                    CRUD.create()
                    print('\n')
                except Exception as e:
                    error_report(e)

            elif command == 'read':
                try:
                    CRUD.read()
                    print('\n')
                except Exception as e:
                    error_report(e)

            elif command == 'update':
                try:
                    CRUD.update()
                    print('\n')
                except Exception as e:
                    error_report(e)

            elif command == 'delete':
                try:
                    CRUD.delete()
                    print('\n')
                except Exception as e:
                    error_report(e)

            elif command == 'export':
                try:
                    export.export('a', 'exported-data.csv', '')
                    print('\n')
                except Exception as e:
                    error_report(e)

            elif command == 'exit':
                run = False

            else:
                print('Wrong input.')
                prompt = input('Do you want to try again? y/n: ')
                if prompt == 'n':
                    creating = False
def post_createStock(newTicker):
    postData = request.body.read()
    print(str(newTicker) + " " + str(postData))
    input_dict = json.loads(postData)
    print(input_dict)
    CRUD.create(input_dict)