コード例 #1
0
async def delete_authors(postgres_pool: asyncpg.pool.Pool, authors_ids_to_delete: Set[int]):
    await asyncio.gather(
        postgres_pool.executemany(
            "DELETE FROM bookauthor WHERE author_id = $1", [(x, ) for x in authors_ids_to_delete]
        ),
        postgres_pool.executemany(
            "DELETE FROM author_annotation WHERE author_id = $1", [(x, ) for x in authors_ids_to_delete]
        )
    )
    await postgres_pool.executemany(
        "DELETE FROM author WHERE id = $1", [(x, ) for x in authors_ids_to_delete]
    )
コード例 #2
0
async def delete_books(postgres_pool: asyncpg.pool.Pool,
                       books_ids_to_delete: Set[int]):
    await asyncio.gather(
        postgres_pool.executemany("DELETE FROM bookauthor WHERE book_id = $1",
                                  [(x, ) for x in books_ids_to_delete]),
        postgres_pool.executemany("DELETE FROM seq WHERE book_id = $1",
                                  [(x, ) for x in books_ids_to_delete]),
        postgres_pool.executemany(
            "DELETE FROM book_annotation WHERE book_id = $1",
            [(x, ) for x in books_ids_to_delete]),
        postgres_pool.executemany("DELETE FROM translator WHERE book_id = $1",
                                  [(x, ) for x in books_ids_to_delete]))
    await postgres_pool.executemany("DELETE FROM book WHERE id = $1",
                                    [(x, ) for x in books_ids_to_delete])