Ejemplo n.º 1
0
def add_book():
    view_writers()
    autor_id = None
    while True:
        autor_id = input("Please enter autor ID: ")
        query = (f"SELECT id FROM {WRITERS.TABLE_NAME} WHERE id = {autor_id}")
        writers = get_data(query)

        if len(autor_id.strip()) > 0 and len(writers) > 0:
            break

    book_name = None
    book_description = None
    while True:
        book_name = input("Please enter book name: ")
        book_description = input("Please enter book description: ")

        if len(book_name.strip()) > 0 and len(book_description.strip()) > 0:
            break

    query = (
        f"INSERT INTO {BOOKS.TABLE_NAME} (name, description, writerId) VALUES ('{book_name}', \
            '{book_description}', {autor_id})")
    execute_command(query)

    print(" Saved ".center(30, "*"))
    print(Fore.GREEN, " Enter <key> comand ".center(30, "*"), Fore.RESET)
Ejemplo n.º 2
0
def add_writer(name):
    autor_name = name
    
    query = ("INSERT INTO {} (name) VALUES ('{}')".format(TABLE_NAME, autor_name))
    execute_command(query)

    print(" Saved ".center(30, "*"))
def add_writer(author_name=None):
    if author_name is None:
        author_name = get_author_name()

    query = ("INSERT INTO {} (name) VALUES ('{}')".format(
        TABLE_NAME, author_name))
    execute_command(query)
    print("Saved")
Ejemplo n.º 4
0
def add_writer():
    autor_name = None
    while True:
        autor_name = input("Please enter autor name: ")

        if len(autor_name.strip()) > 0:
            break
    query = ("INSERT INTO {} (name) VALUES ('{}')".format(
        TABLE_NAME, autor_name))
    execute_command(query)

    print(" Saved ".center(30, "*"))
Ejemplo n.º 5
0
def add_book():
    book_name = None
    book_description = None
    author = None

    while True:
        book_name = input("Enter book name, please: ")
        book_description = input("Enter book description, please: ")
        author = input("Enter author's name, please: ")
        if len(book_name.strip()) > 0 and len(author.strip()) > 0:
            break
    query = ("SELECT id FROM {0} WHERE name = '{1}'".format(WRITERS_TABLE, author))
    author_id = get_data(query)

    if not author_id:
        add_writer(author)
        author_id = get_data(query)
    author_id = author_id[0]['id']

    query = ("INSERT INTO {} (name, description, writerId) VALUES ('{}', '{}', {})"
             .format(BOOK_TABLE, book_name, book_description, author_id))
    execute_command(query)
    print("Saved")