Помогите разобраться!
Курсор выводит: и такие же похожие
new_dict = [
{
"book_id": 59281183,
"book_name": "이세계에서 로그아웃하는 방법",
"book_link": "https://page.kakao.com/home?seriesId=59281183"
},
{
"book_id": 59215376,
"book_name": "대표님, 오늘은 아니에요",
"book_link": "https://page.kakao.com/home?seriesId=59215376"
},
{
"book_id": 59044948,
"book_name": "다시",
"book_link": "https://page.kakao.com/home?seriesId=59044948"
},
{
"book_id": 59271070,
"book_name": "만렙종주",
"book_link": "https://page.kakao.com/home?seriesId=59271070"
},
{
"book_id": 59203735,
"book_name": "ONE",
"book_link": "https://page.kakao.com/home?seriesId=59203735"
},
{
"book_id": 58576019,
"book_name": "쎄븐 크로니클",
"book_link": "https://page.kakao.com/home?seriesId=58576019"
}
]
async def write_to_db(new_dict):
# pprint(new_dict)
connection_db = sqlite3.connect("db/books.db")
cur = connection_db.cursor()
cur.execute("""CREATE TABLE IF NOT EXISTS books(
book_id INT PRIMARY KEY,
book_name TEXT,
book_link TEXT);
""")
connection_db.commit()
# total_item = len(new_dict)
# total = 0
for item in new_dict:
# total += 1
book_id = item["book_id"]
request_db = f'SELECT * FROM books WHERE {book_id}'
book_info = cur.execute(request_db)
print(book_info)
if book_info.fetchone() is None:
print("Прошел проверку!")
book = (item["book_id"], item["book_name"], item["book_link"])
cur.execute("INSERT INTO books VALUES(?, ?, ?);", book)
else:
print("Не прошел проверку!")
continue