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

posted @ 2019-06-20 18:39  焜掱玚  阅读(410)  评论(0编辑  收藏  举报
levels of contents