예제 #1
0
def create_library(cursor, row):
    _row = sqlite3.Row(cursor, row)

    library = Library()
    library.id = _row["id"]
    library.title = _row["title"]
    library.address = _row["address"]

    # Note: You are adding a blank books list to the library object
    # This list will be populated later (see below)
    library.books = []

    book = Book()
    book.id = _row["book_id"]
    book.title = _row["book_title"]
    book.Author = _row["Author"]
    book.ISBNnumber = _row["ISBNnumber"]
    book.YearPublished = _row["YearPublished"]

    # Return a tuple containing the library and the
    # book built from the data in the current row of
    # the data set
    return (
        library,
        book,
    )
예제 #2
0
def create_book(cursor, row):
    _row = sqlite3.Row(cursor, row)

    book = Book()
    book.id = _row["book_id"]
    book.Author = _row["Author"]
    book.ISBNNumber = _row["ISBNNumber"]
    book.bookTitle = _row["bookTitle"]
    book.YearPublished = _row["YearPublished"]

    librarian = Librarian()
    librarian.id = _row["librarian_id"]
    librarian.first_name = _row["first_name"]
    librarian.last_name = _row["last_name"]

    library = Library()
    library.id = _row["library_id"]
    library.title = _row["library_name"]

    book.librarian = librarian
    book.location = library

    return book