import pymysql
conn = pymysql.connect(host='localhost', port=3306, user='root', passwd='231495877')
curs = conn.cursor()
try:
curs.execute('create database hashaki')
except:
print('Database hashaki exists!')
conn.select_db('hashaki')
try:
curs.execute('create table hashakifields(id int PRIMARY KEY NOT NULL,name text)')
except:
print('The table hashakifields exists!')
sql = """INSERT INTO EMPLOYEE(FIRST_NAME,
LAST_NAME, AGE, SEX, INCOME)
VALUES ('Mac', 'Mohan', 20, 'M', 2000)"""
try:
curs.execute(sql)
conn.commit()
except:
conn.rollback()
conn.commit()
curs.close()
conn.close()