Write Python code to create a table Faculty with following fields.
Id, LastName, FirstName, LocationId, phone, rank, startdate
Rank should be one of the following
ASSO, FULL, ASST, INST
Answer:
import mysql.connector.connect
db=mysql.connector.connect('localhost','root','root','College')
cursor=db.cursor()
sql="create table Faculty(Id int,LastName varchar(15),FirstName
varchar(15),LocationId int,phone int,rank varchar(4) check(rank
IN('ASSO','FULL','ASST','INST')),startdate date)"
try:
cursor.execute(sql)
db.commit()
except:
db.rollback()
db.close()