Commit 13d56d14 authored by 王英豪's avatar 王英豪

2.1拉新

parent 58c956f6
Pipeline #1820 canceled with stages
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredPackages">
<value>
<list size="1">
<item index="0" class="java.lang.String" itemvalue="request" />
</list>
</value>
</option>
</inspection_tool>
</profile>
</component>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/testTools.iml" filepath="$PROJECT_DIR$/.idea/testTools.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.7" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
from utils.handle_db import HandleDB
def deleteMemberInformation(user_phone, host, port, user, password):
"""
消费地图 2.1 删除用户 操作
清除会员信息-用户可重新注册
:param user_phone: 用户手机号列表
:param host: mysql-host
:param port: mysql-端口号
:param user: mysql-用户名
:param password: mysql-密码
:return:
"""
for phone in user_phone:
print('删除的手机号:' + phone)
database = 'shopxx'
database2 = 'distribution'
db = HandleDB(host, port, user, password, database)
try:
# 通过手机号查询会员信息
sql = "select id,phone from xx_member where phone='%s'" % phone
user_id = db.select_one_data(sql)['id']
print((db.select_one_data(sql)['id']))
# 删除会员相关数据
sql2 = "delete from xx_member where id='%s'" % user_id
print('删除会员相关数据 ' + sql2)
db.update(sql2)
# 删除会员订单信息
sql3 = "delete from master_xx_order_202105 where member='%s'" % user_id
print('删除会员订单信息 ' + sql3)
db.update(sql3)
# 删除优惠券发放记录
sql4 = "delete from xx_coupon_code where member='%s'" % user_id
print('删除优惠券发放记录 ' + sql4)
db.update(sql4)
db.close()
# 连接 数据库-distribution
db2 = HandleDB(host, port, user, password, database2)
# 删除邀新活动绑定关系(数据库:distribution)
sql5 = "delete from user_invite_records where invited_id='%s'" % user_id
print('删除邀新活动绑定关系 ' + sql5)
db2.update(sql5)
db2.close()
except Exception as e:
print('该手机号已删除过')
pass
if __name__ == '__main__':
# 需要删除的用户手机号
user_phone = [
# '18295949385',
'15810937212',
'13641219957',
# '15300065395'
]
# 删除手机号方法
deleteMemberInformation(user_phone, '172.16.4.6', 30535, 'qa', 'qatest')
# This is a sample Python script.
# Press ⌃R to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
print(f'Hi, {name}') # Press ⌘F8 to toggle the breakpoint.
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
print_hi('PyCharm')
# See PyCharm help at https://www.jetbrains.com/help/pycharm/
# -*- coding: utf-8 -*-
# @Time : 2021/10/26 19:57
# @Author : wangyinghao
# @File : handle_db.py
# @Software: PyCharm
import pymysql
class HandleDB:
def __init__(self, host, port, user, password, databases):
# 连接数据库,创建游标。
self.host = host
self.port = port
self.user = user
self.password = password
self.databases = databases
# 1、建立连接
self.conn = pymysql.connect(
host=self.host,
port=self.port,
user=self.user,
password=self.password,
database=self.databases,
charset="utf8",
cursorclass=pymysql.cursors.DictCursor
)
# 2、创建游标
self.cur = self.conn.cursor()
def select_one_data(self, sql):
self.conn.commit()
self.cur.execute(sql)
return self.cur.fetchone()
def select_all_data(self, sql):
self.conn.commit()
self.cur.execute(sql)
return self.cur.fetchall()
def get_count(self, sql):
self.conn.commit()
return self.cur.execute(sql)
def update(self, sql):
"""
对数据库进行增、删、改的操作。
:param sql:
:return:
"""
self.cur.execute(sql)
self.conn.commit()
def close(self):
self.cur.close()
self.conn.close()
def execution_results(self, sql):
"""
获取执行结果
:return:
"""
self.cur.execute(sql)
# result_one = self.cur.fetchone()
# print("resutl1 {0}", format(result_one)) # fetchone() 获取一条结果
# result_many = self.cur.fetchmany(3) # fetchmany(n) 获取n条结果
# print("resutl1 {0}", format(result_many))
result_all = self.cur.fetchall() # fetchall() 获取所有结果
print("resutl1 ", format(result_all))
self.cur.close()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment