Practice 1
You are requires to write create the following tables inside your python database through python mysql-connector.
Instructions
- Individual Assignment
- Deadline: Thurusday: 24 Dec 2020
- Assignment will be discussed in the next tutorial
Helpers
- Create the following table:
Python/SQL query:
please run the following python code to create the database and the tables
import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd="mysql"
)
mycursor = mydb.cursor()
mycursor.execute("CREATE DATABASE databaseSubmissions")
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd="mysql",
database="databaseSubmissions"
)
mycursor = mydb.cursor()
mycursor.execute("CREATE TABLE Doctors (name VARCHAR(255),department VARCHAR(255), id INT, PRIMARY KEY(id))")
mycursor.execute("CREATE TABLE Patients (name VARCHAR(255), id INT, PRIMARY KEY(id))")
mycursor.execute("CREATE TABLE DOC_PAT ( D_code INT, P_code INT, FOREIGN KEY (P_code) REFERENCES Patients(id),FOREIGN KEY (D_code) REFERENCES Doctors(id))")
Write a python program for doctors hospital that:
- asks to add new doctor
- asks to add new patient
- asks to relate patient and doctor
- asks to view list of doctors names
- asks to view list of patients names
- asks to view list of patient and corresponding doctor
- terminate a patient doctor relationship
- view patients names supervised by selected doctor
- view doctors names supervises a selected patient
please following ths same style in the following video video