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__":