async def update_book(pool: asyncpg.pool.Pool, logger: logging.Logger, book: Book) -> Book: async with pool.acquire() as connection: connection: asyncpg.connection.Connection column: Tuple[int, int] = (book.get_assessment(), book.get_id()) await connection.execute( UPDATE_BOOK.format(table_name=get_table_name()), *column) logger.info( f"UPDATE book: (id: {book.get_id()}, name: {book.get_name()}, " f"author: {book.get_author()}), assessment: {book.get_assessment()})" ) del column return book
async def delete_book(pool: asyncpg.pool.Pool, logger: logging.Logger, book: Book, delete: bool = True) -> Book: async with pool.acquire() as connection: connection: asyncpg.connection.Connection column: Tuple[bool, datetime, int] = (delete, datetime.now(), book.get_id()) await connection.execute( DELETE_BOOK.format(table_name=get_table_name()), *column) logger.info( f"DELETE book: (id: {book.get_id()}, name: {book.get_name()}, " f"author: {book.get_author()}), assessment: {book.get_assessment()})" ) del column return book