YusufSimsek's picture
Add bookstore tool-calling assistant project
58f6928 verified
Raw
History Blame Contribute Delete
7.54 kB
from data.database import get_connection, initialize_database
SAMPLE_BOOKS = [
{
"title": "1984",
"author": "George Orwell",
"category": "Distopya",
"price": 180.00,
"stock": 10,
},
{
"title": "Hayvan Çiftliği",
"author": "George Orwell",
"category": "Distopya",
"price": 145.00,
"stock": 13,
},
{
"title": "Cesur Yeni Dünya",
"author": "Aldous Huxley",
"category": "Distopya",
"price": 195.00,
"stock": 7,
},
{
"title": "Fahrenheit 451",
"author": "Ray Bradbury",
"category": "Distopya",
"price": 175.00,
"stock": 8,
},
{
"title": "Dune",
"author": "Frank Herbert",
"category": "Bilim Kurgu",
"price": 320.00,
"stock": 7,
},
{
"title": "Dune Mesihi",
"author": "Frank Herbert",
"category": "Bilim Kurgu",
"price": 285.00,
"stock": 5,
},
{
"title": "Vakıf",
"author": "Isaac Asimov",
"category": "Bilim Kurgu",
"price": 260.00,
"stock": 9,
},
{
"title": "Ben, Robot",
"author": "Isaac Asimov",
"category": "Bilim Kurgu",
"price": 230.00,
"stock": 6,
},
{
"title": "Marslı",
"author": "Andy Weir",
"category": "Bilim Kurgu",
"price": 290.00,
"stock": 8,
},
{
"title": "Otostopçunun Galaksi Rehberi",
"author": "Douglas Adams",
"category": "Bilim Kurgu",
"price": 245.00,
"stock": 11,
},
{
"title": "Simyacı",
"author": "Paulo Coelho",
"category": "Roman",
"price": 150.00,
"stock": 8,
},
{
"title": "Körlük",
"author": "José Saramago",
"category": "Roman",
"price": 210.00,
"stock": 4,
},
{
"title": "Serenad",
"author": "Zülfü Livaneli",
"category": "Roman",
"price": 225.00,
"stock": 10,
},
{
"title": "Kürk Mantolu Madonna",
"author": "Sabahattin Ali",
"category": "Roman",
"price": 135.00,
"stock": 15,
},
{
"title": "İnce Memed",
"author": "Yaşar Kemal",
"category": "Roman",
"price": 280.00,
"stock": 7,
},
{
"title": "Tutunamayanlar",
"author": "Oğuz Atay",
"category": "Roman",
"price": 340.00,
"stock": 6,
},
{
"title": "Saatleri Ayarlama Enstitüsü",
"author": "Ahmet Hamdi Tanpınar",
"category": "Roman",
"price": 220.00,
"stock": 8,
},
{
"title": "Suç ve Ceza",
"author": "Fyodor Dostoyevski",
"category": "Klasik",
"price": 240.00,
"stock": 6,
},
{
"title": "Karamazov Kardeşler",
"author": "Fyodor Dostoyevski",
"category": "Klasik",
"price": 390.00,
"stock": 4,
},
{
"title": "Sefiller",
"author": "Victor Hugo",
"category": "Klasik",
"price": 360.00,
"stock": 5,
},
{
"title": "Monte Cristo Kontu",
"author": "Alexandre Dumas",
"category": "Klasik",
"price": 410.00,
"stock": 3,
},
{
"title": "Anna Karenina",
"author": "Lev Tolstoy",
"category": "Klasik",
"price": 375.00,
"stock": 5,
},
{
"title": "Vadideki Zambak",
"author": "Honoré de Balzac",
"category": "Klasik",
"price": 170.00,
"stock": 7,
},
{
"title": "Yüzüklerin Efendisi",
"author": "J. R. R. Tolkien",
"category": "Fantastik",
"price": 450.00,
"stock": 5,
},
{
"title": "Hobbit",
"author": "J. R. R. Tolkien",
"category": "Fantastik",
"price": 275.00,
"stock": 9,
},
{
"title": "Harry Potter ve Felsefe Taşı",
"author": "J. K. Rowling",
"category": "Fantastik",
"price": 260.00,
"stock": 12,
},
{
"title": "Taht Oyunları",
"author": "George R. R. Martin",
"category": "Fantastik",
"price": 390.00,
"stock": 6,
},
{
"title": "Küçük Prens",
"author": "Antoine de Saint-Exupéry",
"category": "Çocuk",
"price": 120.00,
"stock": 12,
},
{
"title": "Şeker Portakalı",
"author": "José Mauro de Vasconcelos",
"category": "Çocuk",
"price": 155.00,
"stock": 10,
},
{
"title": "Momo",
"author": "Michael Ende",
"category": "Çocuk",
"price": 190.00,
"stock": 8,
},
{
"title": "Sapiens",
"author": "Yuval Noah Harari",
"category": "Tarih",
"price": 290.00,
"stock": 9,
},
{
"title": "Homo Deus",
"author": "Yuval Noah Harari",
"category": "Tarih",
"price": 310.00,
"stock": 7,
},
{
"title": "Nutuk",
"author": "Mustafa Kemal Atatürk",
"category": "Tarih",
"price": 250.00,
"stock": 14,
},
{
"title": "Doğu Ekspresinde Cinayet",
"author": "Agatha Christie",
"category": "Polisiye",
"price": 185.00,
"stock": 9,
},
{
"title": "Sherlock Holmes: Kızıl Dosya",
"author": "Arthur Conan Doyle",
"category": "Polisiye",
"price": 165.00,
"stock": 8,
},
{
"title": "Ejderha Dövmeli Kız",
"author": "Stieg Larsson",
"category": "Polisiye",
"price": 280.00,
"stock": 5,
},
{
"title": "İnsanın Anlam Arayışı",
"author": "Viktor E. Frankl",
"category": "Psikoloji",
"price": 190.00,
"stock": 11,
},
{
"title": "Düşünme, Hızlı ve Yavaş",
"author": "Daniel Kahneman",
"category": "Psikoloji",
"price": 350.00,
"stock": 6,
},
{
"title": "Sofinin Dünyası",
"author": "Jostein Gaarder",
"category": "Felsefe",
"price": 275.00,
"stock": 8,
},
{
"title": "Devlet",
"author": "Platon",
"category": "Felsefe",
"price": 215.00,
"stock": 7,
},
]
def seed_books() -> None:
"""Örnek kitapları veritabanına ekler."""
initialize_database()
query = """
INSERT OR IGNORE INTO books (
title,
author,
category,
price,
stock
)
VALUES (?, ?, ?, ?, ?)
"""
with get_connection() as connection:
for book in SAMPLE_BOOKS:
connection.execute(
query,
(
book["title"],
book["author"],
book["category"],
book["price"],
book["stock"],
),
)
connection.commit()
book_count = connection.execute(
"SELECT COUNT(*) AS total FROM books"
).fetchone()["total"]
print("Örnek kitaplar başarıyla eklendi.")
print(f"Veritabanındaki toplam kitap sayısı: {book_count}")
if __name__ == "__main__":
seed_books()