# -*- CODING:UTF-8 -*-
# Author :'陈娟_Arwen',
# Date :2019/11/14 16:12
# FileName:mysql
#IDE :PyCharm
import pymysql.cursors
import md5
conn = pymysql.connect(
host='139.199.110.55',
port=3306,
user='root',
password='Rekoon@cn2018',
db='shop',
charset='utf8'
)
cursor = conn.cursor()
def eventId(deviceId):
ak = 0
sql = "SELECT id FROM ld_ad_match WHERE ld_ad_match.idfa = '%s' OR ld_ad_match.imei = '%s'"%(deviceId, deviceId)
cursor.execute(sql)
ak = cursor.fetchone()
return ak
def selects(deviceId):
deviceIdMD5 = md5.md5_encrypt(deviceId)
device_sql = "select * from ld_mobile_device_id where device_id LIKE '%s%s';" % (deviceId, "%")
cursor.execute(device_sql)
print("ld_mobile_device_id表中删除的数据为:", cursor.fetchone())
callback_sql = "SELECT * FROM ld_toutiao_callback WHERE idfa = '%s' or imei = '%s'" % (deviceIdMD5, deviceIdMD5)
cursor.execute(callback_sql)
print("ld_toutiao_callback表中删除的数据为:", cursor.fetchone())
request_sql = "SELECT * FROM ld_toutiao_request WHERE idfa = '%s' OR imei = '%s'" % (deviceIdMD5, deviceIdMD5)
cursor.execute(request_sql)
print("ld_toutiao_request表中删除的数据为:", cursor.fetchone())
event_sql = "SELECT id FROM ld_ad_match WHERE ld_ad_match.idfa = '%s' OR ld_ad_match.imei = '%s'" % (deviceIdMD5,
deviceIdMD5)
cursor.execute(event_sql)
print("ld_ad_event表中删除的数据为:", cursor.fetchone())
match_sql = "SELECT * FROM `ld_ad_match` WHERE imei = '%s' OR idfa = '%s'" % (deviceIdMD5, deviceIdMD5)
cursor.execute(match_sql)
print("ld_ad_match表中删除的数据为:", cursor.fetchone())
def deletes (deviceId):
deviceIdMD5 = md5.md5_encrypt(deviceId)
deviceId1 =eventId(md5.md5_encrypt(deviceId))
if deviceId1 == None:
print("value为空")
else:
event_sql = "DELETE FROM ld_ad_event WHERE ad_match_id = '%s'" % (deviceId1)
cursor.execute(event_sql)
device_sql = "delete from ld_mobile_device_id where device_id LIKE '%s%s';" % (deviceId, "%")
callback_sql = "DELETE FROM ld_toutiao_callback WHERE idfa = '%s' or imei = '%s'" % (deviceIdMD5, deviceIdMD5)
request_sql = "DELETE FROM ld_toutiao_request WHERE idfa = '%s' OR imei = '%s'" % (deviceIdMD5, deviceIdMD5)
request_sql = "DELETE FROM ld_ad_match WHERE idfa = '%s' OR imei = '%s'"%(deviceIdMD5, deviceIdMD5)
cursor.execute(device_sql)
cursor.execute(callback_sql)
cursor.execute(request_sql)
cursor.execute(request_sql)
print("删除成功!!!")
conn.commit()
if __name__ == "__main__":
deviceId = input("请输入要删除的 idfa 或者 imei :")
selects(deviceId)
deletes(deviceId)
conn.close()