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 ef0303b commit 3f06c25
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions backend/init_db.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand All @@ -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__":
Expand Down

0 comments on commit 3f06c25

Please sign in to comment.