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 c2c78ac commit 650c2f6
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions backend/init_db.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Script to initialize the database and populate with initial data."""

import sqlite3

def create_database_tables(conn):
Expand Down Expand Up @@ -34,21 +36,4 @@ 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()

if __name__ == "__main__":
print("Initializing pet adoption database...")
conn = sqlite3.connect('animal_shelter.db')
create_database_tables(conn)
populate_initial_data(conn)
print("Database setup complete!")
conn.close()

0 comments on commit 650c2f6

Please sign in to comment.