Skip to content

Commit

Permalink
Update init_db.py
Browse files Browse the repository at this point in the history
  • Loading branch information
pdr21001 authored Apr 23, 2025
1 parent abe3e8f commit c7b51af
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion backend/init_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,31 @@ def populate_initial_data(conn):
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()

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_database_tables(conn)

# Populate the database with initial data
populate_initial_data(conn)

conn.close()
print("Database initialized successfully with initial data.")

if __name__ == "__main__":
# Path to the database
db_path = 'animal_shelter.db'
initialize_database(db_path)

0 comments on commit c7b51af

Please sign in to comment.