From e90d151f4934ebcc60cf632f9108d550d4754dbb Mon Sep 17 00:00:00 2001 From: Prince D Rusweka Rwabongoya Date: Wed, 23 Apr 2025 18:46:49 -0400 Subject: [PATCH] Update init_db.py --- backend/init_db.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/backend/init_db.py b/backend/init_db.py index 7b63e84..b7b8776 100644 --- a/backend/init_db.py +++ b/backend/init_db.py @@ -11,31 +11,24 @@ def populate_initial_data(conn): """Populate the database with initial data for testing.""" cursor = conn.cursor() - # Sample animals data animals = [ ('Luna', 'Dog', 'Labrador Mix', 2, 'Playful and energetic', '/images/luna.jpg', 'Available'), ('Oliver', 'Cat', 'Tabby', 4, 'Independent but affectionate', '/images/oliver.jpg', 'Available'), ('Max', 'Dog', 'German Shepherd', 3, 'Loyal and intelligent', '/images/max.jpg', 'Available') ] - + for animal in animals: cursor.execute(''' INSERT INTO animals (name, species, breed, age, personality, image_path, adoption_status) - VALUES (?, ?, ?, ?, ?, ?, ?) - ''', animal) - + VALUES (?, ?, ?, ?, ?, ?, ?)''', animal) + conn.commit() def initialize_database(db_path): """Initialize the database by creating tables and populating initial data.""" conn = sqlite3.connect(db_path) - - # Create the database tables create_tables(conn) - - # Populate the database with initial data populate_initial_data(conn) - conn.close() print("Database initialized successfully with initial data.")