8 changed files with 229 additions and 25 deletions
Split View
Diff Options
-
25InsertData.robot
-
2Opr-Center-RF-Api/000Login/LoginCase.robot
-
18用户资料/DataBase.py
-
53用户资料/Execl.py
-
40用户资料/WXlogin.py
-
BIN用户资料/__pycache__/Execl.cpython-36.pyc
-
89用户资料/input.py
-
27用户资料/phone.py
@ -0,0 +1,18 @@ |
|||
import pymysql |
|||
import xlrd |
|||
|
|||
""" |
|||
一、连接mysql数据库 |
|||
""" |
|||
# 打开数据库连接 |
|||
conn = pymysql.connect( |
|||
host='8.135.8.221', # MySQL服务器地址 |
|||
user='root', # 用户名 |
|||
password='qniaothreetwoonego', # 密码 |
|||
charset='utf8', |
|||
port=3306, # 端口 |
|||
database='dating-agency-service', # 数据库名称 |
|||
) |
|||
|
|||
#断开连接 |
|||
conn.close() |
|||
@ -0,0 +1,53 @@ |
|||
import xlrd |
|||
|
|||
# """ |
|||
# 二、读取excel文件 |
|||
# """ |
|||
# FilePath = 'D:/LYL/Study/Robot_framework/space/Dating-Agency/相亲用户资料.xls' |
|||
# |
|||
# # 1.打开excel文件 |
|||
# wkb = xlrd.open_workbook(FilePath) |
|||
# # 2.获取sheet |
|||
# sheet = wkb.sheet_by_index(0) # 获取第一个sheet表['用户资料'] |
|||
# # 3.获取总行数 |
|||
# rows_number = sheet.nrows |
|||
# # 4.遍历sheet表中所有行的数据,并保存至一个空列表cap[] |
|||
# cap = [] |
|||
# for i in range(1,rows_number): # 跳过表头 |
|||
# x = sheet.row_values(i) # 获取第i行的值(从0开始算起) |
|||
# cap.append(x) |
|||
# print(cap) |
|||
# |
|||
# |
|||
# for Userinfo in cap: |
|||
# # U = int(Userinfo[0]) |
|||
# Uname = Userinfo[0] |
|||
# Usex = Userinfo[1] |
|||
# Uhight = int(Userinfo[2]) |
|||
# Uwight = int(Userinfo[3]) |
|||
# Uage = int(Userinfo[4]) |
|||
# Ucity = Userinfo[5] |
|||
# Uedu = Userinfo[6] |
|||
# Umarry = Userinfo[7] |
|||
# Uincome = Userinfo[8] |
|||
# Unickname = Userinfo[9] |
|||
# |
|||
|
|||
""" |
|||
读取phone-text.txt文件的第一列数据 |
|||
""" |
|||
phone_list = [] |
|||
try: |
|||
file = open('D:/LYL/Test/ZTB/phone - test.txt', 'r') |
|||
except FileNotFoundError: |
|||
print('File is not found') |
|||
else: |
|||
lines = file.readlines() |
|||
for line in lines: |
|||
a = line.split(',') |
|||
x = a[0] |
|||
phone_list.append(x) |
|||
file.close() |
|||
|
|||
for Phone in phone_list: |
|||
print(Phone) |
|||
@ -0,0 +1,40 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
# import weixin |
|||
from datetime import datetime, timedelta |
|||
from flask import Flask, redirect, request, url_for |
|||
from weixin import WeixinLogin |
|||
|
|||
|
|||
|
|||
app = Flask(__name__) |
|||
|
|||
app_id = 'wx13d6b82e0cf2bd9b' |
|||
app_secret = '' |
|||
wx_login = WeixinLogin(app_id, app_secret) |
|||
|
|||
|
|||
@app.route("/login") |
|||
def login(): |
|||
openid = request.cookies.get("openid") |
|||
next = request.args.get("next") or request.referrer or "/", |
|||
if openid: |
|||
return redirect(next) |
|||
|
|||
callback = url_for("authorized", next=next, _external=True) |
|||
url = wx_login.authorize(callback, "snsapi_base") |
|||
return redirect(url) |
|||
|
|||
|
|||
@app.route("/authorized") |
|||
def authorized(): |
|||
code = request.args.get("code") |
|||
if not code: |
|||
return "ERR_INVALID_CODE", 400 |
|||
next = request.args.get("next", "/") |
|||
data = wx_login.access_token(code) |
|||
openid = data.openid |
|||
resp = redirect(next) |
|||
expires = datetime.now() + timedelta(days=1) |
|||
resp.set_cookie("openid", openid, expires=expires) |
|||
return resp |
|||
@ -0,0 +1,89 @@ |
|||
import pymysql |
|||
import xlrd |
|||
|
|||
""" |
|||
一、连接mysql数据库 |
|||
""" |
|||
# 打开数据库连接 |
|||
conn = pymysql.connect( |
|||
host='8.135.8.221', # MySQL服务器地址 |
|||
user='root', # 用户名 |
|||
password='qniaothreetwoonego', # 密码 |
|||
charset='utf8', # |
|||
port=3308, # 端口 |
|||
db='dating-agency-service', # 数据库名称 |
|||
) |
|||
|
|||
# 使用cursor()方法获取操作游标 |
|||
c = conn.cursor() |
|||
|
|||
|
|||
# """ |
|||
# 二、读取excel文件 |
|||
# """ |
|||
# FilePath = 'D:/LYL/Study/Robot_framework/space/Dating-Agency/相亲用户资料.xls' |
|||
# |
|||
# # 1.打开excel文件 |
|||
# wkb = xlrd.open_workbook(FilePath) |
|||
# # 2.获取sheet |
|||
# sheet = wkb.sheet_by_index(0) # 获取第一个sheet表['用户资料'] |
|||
# # 3.获取总行数 |
|||
# rows_number = sheet.nrows |
|||
# # 4.遍历sheet表中所有行的数据,并保存至一个空列表cap[] |
|||
# cap = [] |
|||
# for i in range(1,rows_number): |
|||
# x = sheet.row_values(i) # 获取第i行的值(从0开始算起) |
|||
# cap.append(x-1) |
|||
# print(cap) |
|||
|
|||
# """ |
|||
# 三、将读取到的数据批量插入数据库 |
|||
# """ |
|||
# for Userinfo in cap: |
|||
# # U = int(Userinfo[0]) |
|||
# Uname = Userinfo[0] |
|||
# Usex = Userinfo[1] |
|||
# Uhight = int(Userinfo[2]) |
|||
# Uwight = int(Userinfo[3]) |
|||
# Uage = int(Userinfo[4]) |
|||
# Ucity = Userinfo[5] |
|||
# Uedu = Userinfo[6] |
|||
# Umarry = Userinfo[7] |
|||
# Uincome = Userinfo[8] |
|||
# Unickname = Userinfo[9] |
|||
# # 使用f-string格式化字符串,对sql进行赋值 |
|||
# c.execute(f"insert into student(Sno,Sname,Ssex,Sage,Sdept) value ('{Uname}','{Usex}','{Uhight}','{Uage}','{Ucity}','{Uedu}','{Umarry}','{Uincome}','{Unickname}')") |
|||
# conn.commit() |
|||
# conn.close() |
|||
# print("插入数据完成!") |
|||
|
|||
|
|||
""" |
|||
读取phone-text.txt文件的第一列数据 |
|||
""" |
|||
phone_list = [] |
|||
try: |
|||
file = open('D:/LYL/Test/ZTB/phone - test.txt', 'r') |
|||
except FileNotFoundError: |
|||
print('File is not found') |
|||
else: |
|||
lines = file.readlines() |
|||
for line in lines: |
|||
a = line.split(',') |
|||
x = a[0] |
|||
phone_list.append(x) |
|||
file.close() |
|||
# |
|||
for Phone in phone_list: |
|||
print(Phone) |
|||
|
|||
|
|||
|
|||
""" |
|||
三、查询数据库account表中tid=Phone的所有数据 |
|||
""" |
|||
for Phone in phone_list: |
|||
print(Phone) |
|||
c.execute(f"SELECT * FROM `uec`.`qn_account` WHERE `tid` = '{Phone}' AND `is_delete` = '0'") |
|||
conn.commit() |
|||
conn.close() |
|||
@ -0,0 +1,27 @@ |
|||
import random |
|||
|
|||
# def create_a_phone(): |
|||
# # 第二位数字 |
|||
# second = [3, 4, 5, 7, 8][random.randint(0, 4)] |
|||
# # 第三位数字 |
|||
# third = {3: random.randint(0, 9), |
|||
# 4: [5, 7, 9][random.randint(0, 2)], |
|||
# 5: [i for i in range(10) if i != 4][random.randint(0, 8)], |
|||
# 7: [i for i in range(10) if i not in [4, 9]][random.randint(0, 7)], |
|||
# 8: random.randint(0, 9), }[second] |
|||
# # **后八位数字 |
|||
# suffix = random.randint(9999999, 100000000) |
|||
# # 拼接手机号 |
|||
# return "1{}{}{}".format(second, third, suffix) |
|||
# |
|||
# create_a_phone() |
|||
|
|||
|
|||
|
|||
def raddomPhone(): |
|||
headList = ["130", "131", "132", "133", "134", "135", "136", "137", "138", "139", |
|||
"147", "150", "151", "152", "153", "155", "156", "157", "158", "159", |
|||
"186", "187", "188", "189"] |
|||
return (random.choice(headList) + "".join(random.choice("0123456789") for i in range(8))) |
|||
|
|||
|
|||
Write
Preview
Loading…
Cancel
Save