Python3 MySQL 数据库连接 - PyMySQL 驱动 笔记

sql插入语句(推荐):

1 str_mac = "nihao"
2 # SQL 插入语句
3 
4 sql = "INSERT INTO EMPLOYEE(FIRST_NAME, \
5        LAST_NAME, AGE, SEX, INCOME) \
6        VALUES ('%s', '%s',  %s,  '%s',  %s)" % \
7       (str_mac, 'Mohan', 20, 'M', 2000)
View Code

sql更新语句:

  常见问题在update set age = age+1 and income=10 。。。数据库会出现age=0

1 sql = "UPDATE EMPLOYEE SET AGE = AGE + 10,INCOME = INCOME+50 WHERE SEX = '%c'" % ('M')
View Code

https://www.runoob.com/python3/python3-mysql.html

猜你喜欢

转载自www.cnblogs.com/my-ordinary/p/11060593.html