def create_book(details: dict, content: str, href: str):
     title = details['title']
     author_name = details['authors'][0]['name']
     a_slug = details['authors'][0]['slug']
     b = Book(book_id=None,
              title=title,
              uri=href,
              age=None,
              author=author_name,
              author_slug=a_slug)
     b.set_content(content)
     return b
Пример #2
0
    def fetch_content(self, book: Book) -> Book:
        connection = sqlite3.connect(config.database['path'])
        cursor = connection.cursor()

        cursor.execute('SELECT content FROM book '
                       'WHERE book.id = :id', {'id': book.get_id()})
        row = cursor.fetchone()

        connection.commit()
        connection.close()

        book.set_content(row[0])
        return book