0% found this document useful (0 votes)
11 views1 page

Add Sample Data - Py

Uploaded by

watermelon1434
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

Add Sample Data - Py

Uploaded by

watermelon1434
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import sqlite3

# Define the database file


DATABASE = 'hospital_management.db'

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)

# Insert Beds for each Department (example: 10 beds per department)


cursor.execute('SELECT id FROM Departments')
department_ids = [row['id'] for row in cursor.fetchall()]
beds = []
for dept_id in department_ids:
for _ in range(10): # Assuming 10 beds per department
beds.append((dept_id, False, None))

cursor.executemany('''
INSERT INTO Beds (department_id, is_occupied, patient_id) VALUES (?, ?, ?)
''', beds)

conn.commit()
conn.close()

if __name__ == "__main__":
add_sample_data()

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy