[pycharm]修改和删除数据
import pymysql
# 获取连接
conn = pymysql.connect(
host='10.105.212.1',
port=3306,
user='root',
password='DemoDemo',
database='db',
charset='utf8'
)
cursor = conn.cursor(pymysql.cursors.DictCursor)
# 更新id=1的用户 name="LIUXU"
update_sql = 'update users set name="LIUXU" where id=1;'
cursor.execute(update_sql)
# 删除id>5的用户数据
delete_sql = 'delete from users where id>5;'
cursor.execute(delete_sql)