SoftTesting/案例3.py
2025-04-15 09:22:27 +08:00

15 lines
326 B
Python

import pymysql
db=pymysql.connect (
host='172.16.1.166',
user='root',
passwd='114514',
database='TESTDB',
)
cursor=db.cursor()
sql="INSERT INTO EMPLOYEE(FIRST_NAME, LAST_NAME, AGE, SEX, INCOME) VALUE ('Mac','Mohan',20,'M',2000)"
try:
cursor.execute(sql)
db.commit()
except:
db.rollback()
db.close()