Add Sample Data - Py
Add Sample Data - Py
def add_sample_data():
conn = sqlite3.connect(DATABASE)
conn.row_factory = sqlite3.Row
cursor = conn.cursor()
# Insert Hospitals
hospitals = [
('City Hospital', '123 Main St, Anytown'),
('Greenwood Medical Center', '456 Elm St, Greenfield'),
('Sunshine Clinic', '789 Oak St, Sunnyville'),
('HealthPlus Hospital', '101 Maple St, Healthtown')
]
cursor.executemany('''
INSERT OR IGNORE INTO Hospitals (name, address) VALUES (?, ?)
''', hospitals)
# Insert Departments
departments = [
('Cardiology', 'Heart-related issues', 1),
('ENT', 'Ear, Nose, and Throat', 1),
('Gastroenterology', 'Digestive system issues', 2),
('Neurology', 'Brain and nervous system', 2),
('Orthopedics', 'Bone and joint issues', 3),
('Pediatrics', 'Children’s health', 3),
('Oncology', 'Cancer treatment', 4),
('Rheumatology', 'Autoimmune diseases', 4),
('Pulmonology', 'Lung issues', 1),
('Urology', 'Urinary tract and male reproductive organs', 4)
]
cursor.executemany('''
INSERT OR IGNORE INTO Departments (name, description, hospital_id) VALUES
(?, ?, ?)
''', departments)
cursor.executemany('''
INSERT INTO Beds (department_id, is_occupied, patient_id) VALUES (?, ?, ?)
''', beds)
conn.commit()
conn.close()
if __name__ == "__main__":
add_sample_data()