chore: 批量新增各类工具脚本与配置文件
1. 新增音频录制、下载、上传相关脚本 2. 新增数据库操作、API调用工具 3. 新增Excel数据处理脚本 4. 新增弱密码检测脚本
This commit is contained in:
+84
-27
@@ -20,7 +20,7 @@
|
||||
"port=3306,\n",
|
||||
"user='root',\n",
|
||||
"password='Abcd@123456',\n",
|
||||
"database='hongxx_video',\n",
|
||||
"database='hongxx',\n",
|
||||
"charset='utf8'\n",
|
||||
")\n",
|
||||
"# 创建游标对象\n",
|
||||
@@ -50,17 +50,17 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": 26,
|
||||
"id": "b717043a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"sql = 'select * from video_info'"
|
||||
"sql = 'select * from sys_user where dept_id=100'\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": 27,
|
||||
"id": "b4b373b8",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -72,46 +72,103 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "84652b4b",
|
||||
"execution_count": 28,
|
||||
"id": "394495d3",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"[2,\n",
|
||||
" 3,\n",
|
||||
" 4,\n",
|
||||
" 6,\n",
|
||||
" 24,\n",
|
||||
" 31,\n",
|
||||
" 308,\n",
|
||||
" 909,\n",
|
||||
" 917,\n",
|
||||
" 918,\n",
|
||||
" 1145,\n",
|
||||
" 3690,\n",
|
||||
" 3698,\n",
|
||||
" 3828,\n",
|
||||
" 3842,\n",
|
||||
" 3843,\n",
|
||||
" 3844,\n",
|
||||
" 3895,\n",
|
||||
" 3899,\n",
|
||||
" 3912,\n",
|
||||
" 3913,\n",
|
||||
" 3935,\n",
|
||||
" 3936,\n",
|
||||
" 3988,\n",
|
||||
" 5440,\n",
|
||||
" 5492,\n",
|
||||
" 7696,\n",
|
||||
" 7713,\n",
|
||||
" 7714,\n",
|
||||
" 7723,\n",
|
||||
" 7728,\n",
|
||||
" 2059454179031199746]"
|
||||
]
|
||||
},
|
||||
"execution_count": 28,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"[i[\"user_id\"] for i in result]\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 25,
|
||||
"id": "325e4664",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"result\n",
|
||||
"# http://192.168.0.244:88/record/original-files/video/522e4c55fc804decafdd0a62e5a1bf74.mp4\n",
|
||||
"for item in result:\n",
|
||||
" if item[\"video_url\"].startswith(\"http://192.168.0.244:88\"):\n",
|
||||
" video_url = item[\"video_url\"].replace(\"http://192.168.0.244:88\",\"/mp4\")\n",
|
||||
" sql = f\"update video_info set video_url='{video_url}' where id={item['id']}\"\n",
|
||||
" cursor.execute(sql)"
|
||||
" userid = item[\"user_id\"]\n",
|
||||
" \n",
|
||||
" sql2 = f\"update sys_user set dept_id=100, team_user_type ='BACKEND' where user_id={userid}\"\n",
|
||||
" cursor.execute(sql2)\n",
|
||||
"connection.commit()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"id": "f62b4e7d",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for item in result:\n",
|
||||
" userid = item[\"user_id\"]\n",
|
||||
" sql2 = f\"update sys_user_dept set dept_id=100, person_type='hx_sys' where user_id={userid}\"\n",
|
||||
" cursor.execute(sql2)\n",
|
||||
"connection.commit()\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "0b4381f4",
|
||||
"id": "7dcf47b8",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "",
|
||||
"evalue": "",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[1;31m在当前单元格或上一个单元格中执行代码时 Kernel 崩溃。\n",
|
||||
"\u001b[1;31m请查看单元格中的代码,以确定故障的可能原因。\n",
|
||||
"\u001b[1;31m单击<a href='https://aka.ms/vscodeJupyterKernelCrash'>此处</a>了解详细信息。\n",
|
||||
"\u001b[1;31m有关更多详细信息,请查看 Jupyter <a href='command:jupyter.viewOutput'>log</a>。"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for item in result:\n",
|
||||
" userid = item[\"user_id\"]\n",
|
||||
" sql2 = f\"update sys_user_role set dept_id=100 where user_id={userid}\"\n",
|
||||
" cursor.execute(sql2)\n",
|
||||
"connection.commit()"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "base",
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "42e17205",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# %%\n",
|
||||
"import pymysql\n",
|
||||
"\n",
|
||||
"# %%\n",
|
||||
"\n",
|
||||
"# 创建数据库连接\n",
|
||||
"connection = pymysql.connect(\n",
|
||||
"host='192.168.0.244',\n",
|
||||
"port=3300,\n",
|
||||
"user='root',\n",
|
||||
"password='hxyd1109',\n",
|
||||
"database='school_server',\n",
|
||||
"charset='utf8'\n",
|
||||
")\n",
|
||||
"cursor = connection.cursor()\n",
|
||||
"# %%\n",
|
||||
"def create_table(cursor,result):\n",
|
||||
" \n",
|
||||
" data = []\n",
|
||||
" for i in result:\n",
|
||||
" list_list = list(i)\n",
|
||||
" des=cursor.description # 获取表详情,字段名,长度,属性等\n",
|
||||
" t = \",\".join([item[0] for item in des])\n",
|
||||
" table_head = t.split(',') # # 查询表列名 用,分割\n",
|
||||
" \n",
|
||||
" dict_result = dict(zip(table_head, list_list)) # 打包为元组的列表 再转换为字典\n",
|
||||
" data.append(dict_result) # 将字典添加到list_result中\n",
|
||||
" return data\n",
|
||||
"\n",
|
||||
"# %%\n",
|
||||
"\n",
|
||||
"# %%\n",
|
||||
"\n",
|
||||
"# %%\n",
|
||||
"sql1 = \"select * from teacher where id=828\"\n",
|
||||
"cursor.execute(sql1)\n",
|
||||
"result=cursor.fetchall()\n",
|
||||
"table_app = create_table(cursor,result)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"id": "54db4116",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"[{'id': 828,\n",
|
||||
" 'tea_name': '彭兰英',\n",
|
||||
" 'sex': 2,\n",
|
||||
" 'phone': '15198039323',\n",
|
||||
" 'type': 6,\n",
|
||||
" 'grade_id': None,\n",
|
||||
" 'class_id': None,\n",
|
||||
" 'user_name': 'ptszxbr9023',\n",
|
||||
" 'team_id': '110',\n",
|
||||
" 'pid': None,\n",
|
||||
" 'serial_no': '1336827486',\n",
|
||||
" 'openid': None,\n",
|
||||
" 'tea_no': 'ptszxbr9023',\n",
|
||||
" 'wx_phone': '15198039323',\n",
|
||||
" 'user_id': None,\n",
|
||||
" 'department_id': None,\n",
|
||||
" 'zt_teacher_uuid': None,\n",
|
||||
" 'hire': '职工',\n",
|
||||
" 'power': '门卫安保',\n",
|
||||
" 'class_type_name': None,\n",
|
||||
" 'hire_id': 98,\n",
|
||||
" 'flag': None,\n",
|
||||
" 'state': 1,\n",
|
||||
" 'sync_source': 'local'}]"
|
||||
]
|
||||
},
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"table_app"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "base",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.12.4"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import pymysql
|
||||
import random
|
||||
import datetime
|
||||
import random
|
||||
# 创建数据库连接
|
||||
connection = pymysql.connect(
|
||||
host='192.168.0.244',
|
||||
port=3300,
|
||||
user='root',
|
||||
password='hxyd1109',
|
||||
database='school_server',
|
||||
charset='utf8'
|
||||
)
|
||||
# 创建游标对象
|
||||
cursor = connection.cursor()
|
||||
orgianl = {'id': 828,
|
||||
'tea_name': '彭兰英',
|
||||
'sex': 2,
|
||||
'phone': '15198039323',
|
||||
'type': 6,
|
||||
'grade_id': None,
|
||||
'class_id': None,
|
||||
'user_name': 'ptszxbr9023',
|
||||
'team_id': '110',
|
||||
'pid': None,
|
||||
'serial_no': '1336827486',
|
||||
'openid': None,
|
||||
'tea_no': 'ptszxbr9023',
|
||||
'wx_phone': '15198039323',
|
||||
'user_id': None,
|
||||
'department_id': None,
|
||||
'zt_teacher_uuid': None,
|
||||
'hire': '职工',
|
||||
'power': '门卫安保',
|
||||
'class_type_name': None,
|
||||
'hire_id': 98,
|
||||
'flag': None,
|
||||
'state': 1,
|
||||
'sync_source': 'local'}
|
||||
sql = f"""
|
||||
UPDATE `school_server`.`teacher` SET `tea_name` = '彭兰英' WHERE `id` = 828;
|
||||
"""
|
||||
cursor.execute(sql)
|
||||
connection.commit()
|
||||
cursor.close()
|
||||
connection.close()
|
||||
@@ -2,7 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": 1,
|
||||
"id": "b82fd271",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -27,7 +27,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": 2,
|
||||
"id": "759c550a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
|
||||
Reference in New Issue
Block a user