6.8 KiB
6.8 KiB
In [13]:
import pymysql
import snowflake
from faker import Faker
fake = Faker('zh_CN')
import random
# 创建数据库连接
connection = pymysql.connect(
host='192.168.0.244',
user='root',
password='Abcd@123456',
database='qy_school',
charset='utf8'
)
# 创建游标对象
cursor = connection.cursor()
sql="select * from student"
cursor.execute(sql)
result=cursor.fetchall()In [14]:
sql="select * from student"
cursor.execute(sql)
result=cursor.fetchall()In [17]:
# ids = []
# for item in result:
# id = item[0]
# ids.append(id)
ids = [9131, 9135, 9139, 9140, 9141, 9142, 9151]In [3]:
sql = "select * from t_camera"
cursor.execute(sql)
camera=cursor.fetchall()
channels = []In [5]:
for item in camera:
channels.append(item[17])In [ ]:
import uuid
'dffa5eac-49aa-48d2-a6c1-deedbff0b46a'
In [18]:
from requests import get,post
import time
from datetime import datetime
ip = "http://192.168.0.209:8101"
param = {
"username": "tangchao",
"password": "123456a",
"client_id": "client",
"grant_type": "password",
"client_secret": "123456",
}
data = get(url=f"{ip}/oauth/token",params=param).json()
token = data["access_token"]
header = {
"content-type": "application/json",
"authorization": f"Bearer {token}",
}
In [ ]:
times = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
count = random.randint(1, 4)
channel = random.choice(channels)
data = {
"batch_info": {
"batch_id": str(uuid.uuid4()),
"detected_image_path":"",
"total_faces": count,
"cameraid": "camera_001",
"cameracode": "CAM001"
},
"results":None
}
child = []
for item in random.choices(ids, k=count):
tem = {
"sim": "0.876",
"simFaceurl": "",
"baseFacesurl": "",
"faceBaseid": "",
"name": "",
"sex": "",
"empid": f"{item}",
"telephone": "",
"remark": "",
"channel": f"{channel}",
"ename": "Face",
"cname": "人脸比对",
"createtime": times
}
child.append(tem)
data["results"] = child
post(f"{ip}/ai/stuface/receive",json=data,headers=header).text'{"success":true,"msg":"操作成功","code":0,"data":null}'[1;31m在当前单元格或上一个单元格中执行代码时 Kernel 崩溃。 [1;31m请查看单元格中的代码,以确定故障的可能原因。 [1;31m单击<a href='https://aka.ms/vscodeJupyterKernelCrash'>此处</a>了解详细信息。 [1;31m有关更多详细信息,请查看 Jupyter <a href='command:jupyter.viewOutput'>log</a>。
In [68]:
dataOut [68]:
{'batch_info': {'batch_id': '6a6e425b-e3b5-46d8-8b53-4aa9f2f75fac',
'detected_image_path': 'https://cdn2.thedogapi.com/images/lQH1NRsGE.jpg',
'total_faces': 3,
'cameraid': 'camera_001',
'cameracode': 'CAM001'},
'results': [{'sim': '0.876',
'simFaceurl': '',
'baseFacesurl': '',
'faceBaseid': '',
'name': '',
'sex': '',
'empid': '9146',
'telephone': '',
'remark': '',
'channel': '12',
'ename': 'Face',
'cname': '人脸比对',
'createtime': '2025-10-14 19:05:30'},
{'sim': '0.876',
'simFaceurl': '',
'baseFacesurl': '',
'faceBaseid': '',
'name': '',
'sex': '',
'empid': '9121',
'telephone': '',
'remark': '',
'channel': '12',
'ename': 'Face',
'cname': '人脸比对',
'createtime': '2025-10-14 19:05:30'},
{'sim': '0.876',
'simFaceurl': '',
'baseFacesurl': '',
'faceBaseid': '',
'name': '',
'sex': '',
'empid': '9132',
'telephone': '',
'remark': '',
'channel': '12',
'ename': 'Face',
'cname': '人脸比对',
'createtime': '2025-10-14 19:05:30'}]}