根据ID删除MySQL数据库以及iPad上数据
"""
author:张鑫
date:2021/7/30 20:39
"""
import requests
import pymysql
connect = pymysql.Connect(
host='140.210.4.73',
port=3306,
user='twipad_cj',
passwd='bj@#twipad_cj',
db='tw_ipaddb',
charset='utf8mb4'
)
cursor = connect.cursor()
keyword_list = []
for lines in open('接口ID', encoding='utf8'):
lines = lines.strip()
keyword_list.append(lines)
print(f'keyword_list={keyword_list}')
for keyword_list in keyword_list:
url = f'http://twipad.hnxinxiudata.top/api/data/del_data?tablename=hkby_facebookhistory_abroaddataall&id={keyword_list}'
html = requests.get(url)
print(html)
# 增加数据
# sql1 = 'insert into kasaer(name,age,score) values (1,2,3)'
# 删除数据,1是字符串
sql = f'delete from hkby_facebookhistory_abroaddataall where ir_id={keyword_list}'
# 修改数据
# sql='update kasaer set age=18,score=80 where name="路明非" '
# 查询数据
# sql2 = 'select * from kasaer'
data1 = cursor.execute(sql)
print(data1)
connect.commit()
print('修改成功')
connect.close()