Consider the structure of table Doctor given
below
Doctor
Doctor_id(p)
Doctor_Name
Hospital_id(F)
Joining_Date
Speciality
Salary Experience.
Write Python code to create the above table.
Answer:
import mysql.connector
mydb=mysql.connector.connect("localhost","root","root","Hospital")
cursor=mydb.cursor()
sql="create table Doctor(Doctor_id int primary key,Doctor_Name
varchar(20),Hospital_id int foreign key,Joining_dat date,Speciality
varchar(45),Salary int,Experience int)"
cursor.execute(sql)
cursor.close()
mydb.close()