from data.database import DATABASE_PATH, get_connection, initialize_database from data.seed_database import seed_books def list_books() -> None: """Veritabanındaki bütün kitapları ekrana yazdırır.""" with get_connection() as connection: books = connection.execute( """ SELECT id, title, author, category, price, stock FROM books ORDER BY id """ ).fetchall() print("\n" + "=" * 90) print("KİTAP LİSTESİ") print("=" * 90) for book in books: print( f"ID: {book['id']} | " f"Kitap: {book['title']} | " f"Yazar: {book['author']} | " f"Kategori: {book['category']} | " f"Fiyat: {book['price']:.2f} TL | " f"Stok: {book['stock']}" ) print("=" * 90) print(f"Toplam kitap: {len(books)}") def main() -> None: initialize_database() seed_books() list_books() print(f"\nVeritabanı dosyası: {DATABASE_PATH}") print("✅ Veritabanı testi başarıyla tamamlandı.") if __name__ == "__main__": main()