From 3f06c251be45a1e91956adcfb85f441422a71dc5 Mon Sep 17 00:00:00 2001 From: Prince D Rusweka Rwabongoya Date: Wed, 23 Apr 2025 17:56:44 -0400 Subject: [PATCH] Update init_db.py --- backend/init_db.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/init_db.py b/backend/init_db.py index 8c52eea..3ff33ec 100644 --- a/backend/init_db.py +++ b/backend/init_db.py @@ -1,7 +1,7 @@ import sqlite3 -import random def create_database_tables(conn): + """Create tables for the database if they do not exist.""" cursor = conn.cursor() cursor.execute(''' CREATE TABLE IF NOT EXISTS animals ( @@ -27,21 +27,22 @@ def create_database_tables(conn): conn.commit() 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) - + conn.commit() if __name__ == "__main__":