feat: 添加多个功能模块和工具脚本
- 新增websocket客户端和服务端实现 - 添加图片压缩工具和快速压缩脚本 - 实现学生信息处理相关API - 添加MQTT客户端和消息处理功能 - 更新.gitignore忽略更多文件类型 - 添加数据库操作工具和示例 - 实现多个测试脚本和工具类
This commit is contained in:
File diff suppressed because it is too large
Load Diff
+133
@@ -0,0 +1,133 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "b82fd271",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pymysql\n",
|
||||
"import snowflake\n",
|
||||
"from faker import Faker\n",
|
||||
"import random\n",
|
||||
"import datetime\n",
|
||||
"fake = Faker('zh_CN')\n",
|
||||
"import random\n",
|
||||
"# 创建数据库连接\n",
|
||||
"connection = pymysql.connect(\n",
|
||||
"host='192.168.0.244',\n",
|
||||
"port=3306,\n",
|
||||
"user='root',\n",
|
||||
"password='Abcd@123456',\n",
|
||||
"database='hongxx_video',\n",
|
||||
"charset='utf8'\n",
|
||||
")\n",
|
||||
"# 创建游标对象\n",
|
||||
"cursor = connection.cursor()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "759c550a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"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"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "b717043a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"sql = 'select * from video_info'"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "b4b373b8",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"cursor.execute(sql)\n",
|
||||
"rows = cursor.fetchall()\n",
|
||||
"result = create_table(cursor,rows)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "84652b4b",
|
||||
"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)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "0b4381f4",
|
||||
"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>。"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"connection.commit()"
|
||||
]
|
||||
}
|
||||
],
|
||||
"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,245 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "4ba86c3e",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pymysql\n",
|
||||
"import snowflake\n",
|
||||
"from faker import Faker\n",
|
||||
"import random\n",
|
||||
"import datetime\n",
|
||||
"fake = Faker('zh_CN')\n",
|
||||
"import random\n",
|
||||
"# 创建数据库连接\n",
|
||||
"connection = pymysql.connect(\n",
|
||||
"host='192.168.0.244',\n",
|
||||
"port=3306,\n",
|
||||
"user='root',\n",
|
||||
"password='Abcd@123456',\n",
|
||||
"database='hongxx',\n",
|
||||
"charset='utf8'\n",
|
||||
")\n",
|
||||
"# 创建游标对象\n",
|
||||
"cursor = connection.cursor()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"id": "5db9d7fd",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"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"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"id": "c62fc147",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"'Open-architected analyzing portal'"
|
||||
]
|
||||
},
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"fake.catch_phrase()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"id": "8d091b58",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\n",
|
||||
"INSERT INTO `sys_custom_open_page` \n",
|
||||
"(`parent_id`, `name`, `description`, `page_level`, `biz_type`, `page_type`, \n",
|
||||
"`section_code`, `page_path`, `page_url`, `dept_id`, `del_flag`, `create_by`, \n",
|
||||
"`create_time`, `create_person_id`, `create_person_name`, `update_by`, \n",
|
||||
"`update_time`, `update_person_name`, `update_person_id`) \n",
|
||||
"VALUES (3, 'Phas', NULL, '0', 'video', '1', '1245', 'http://www.baidu.com', \n",
|
||||
"NULL, 0, '0', 'xtl', '2026-01-14 17:04:49', 0, 'xtl', 'xtl', \n",
|
||||
"'2026-01-14 17:05:10', 'xtl', 0);\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"INSERT INTO `sys_custom_open_page` \n",
|
||||
"(`parent_id`, `name`, `description`, `page_level`, `biz_type`, `page_type`, \n",
|
||||
"`section_code`, `page_path`, `page_url`, `dept_id`, `del_flag`, `create_by`, \n",
|
||||
"`create_time`, `create_person_id`, `create_person_name`, `update_by`, \n",
|
||||
"`update_time`, `update_person_name`, `update_person_id`) \n",
|
||||
"VALUES (3, 'Bala', NULL, '0', 'video', '1', '1245', 'http://www.baidu.com', \n",
|
||||
"NULL, 0, '0', 'xtl', '2026-01-14 17:04:49', 0, 'xtl', 'xtl', \n",
|
||||
"'2026-01-14 17:05:10', 'xtl', 0);\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"INSERT INTO `sys_custom_open_page` \n",
|
||||
"(`parent_id`, `name`, `description`, `page_level`, `biz_type`, `page_type`, \n",
|
||||
"`section_code`, `page_path`, `page_url`, `dept_id`, `del_flag`, `create_by`, \n",
|
||||
"`create_time`, `create_person_id`, `create_person_name`, `update_by`, \n",
|
||||
"`update_time`, `update_person_name`, `update_person_id`) \n",
|
||||
"VALUES (4, 'Syne', NULL, '0', 'video', '1', '1245', 'http://www.baidu.com', \n",
|
||||
"NULL, 0, '0', 'xtl', '2026-01-14 17:04:49', 0, 'xtl', 'xtl', \n",
|
||||
"'2026-01-14 17:05:10', 'xtl', 0);\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"INSERT INTO `sys_custom_open_page` \n",
|
||||
"(`parent_id`, `name`, `description`, `page_level`, `biz_type`, `page_type`, \n",
|
||||
"`section_code`, `page_path`, `page_url`, `dept_id`, `del_flag`, `create_by`, \n",
|
||||
"`create_time`, `create_person_id`, `create_person_name`, `update_by`, \n",
|
||||
"`update_time`, `update_person_name`, `update_person_id`) \n",
|
||||
"VALUES (2, 'Cust', NULL, '0', 'video', '1', '1245', 'http://www.baidu.com', \n",
|
||||
"NULL, 0, '0', 'xtl', '2026-01-14 17:04:49', 0, 'xtl', 'xtl', \n",
|
||||
"'2026-01-14 17:05:10', 'xtl', 0);\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"INSERT INTO `sys_custom_open_page` \n",
|
||||
"(`parent_id`, `name`, `description`, `page_level`, `biz_type`, `page_type`, \n",
|
||||
"`section_code`, `page_path`, `page_url`, `dept_id`, `del_flag`, `create_by`, \n",
|
||||
"`create_time`, `create_person_id`, `create_person_name`, `update_by`, \n",
|
||||
"`update_time`, `update_person_name`, `update_person_id`) \n",
|
||||
"VALUES (2, 'Stre', NULL, '0', 'video', '1', '1245', 'http://www.baidu.com', \n",
|
||||
"NULL, 0, '0', 'xtl', '2026-01-14 17:04:49', 0, 'xtl', 'xtl', \n",
|
||||
"'2026-01-14 17:05:10', 'xtl', 0);\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"INSERT INTO `sys_custom_open_page` \n",
|
||||
"(`parent_id`, `name`, `description`, `page_level`, `biz_type`, `page_type`, \n",
|
||||
"`section_code`, `page_path`, `page_url`, `dept_id`, `del_flag`, `create_by`, \n",
|
||||
"`create_time`, `create_person_id`, `create_person_name`, `update_by`, \n",
|
||||
"`update_time`, `update_person_name`, `update_person_id`) \n",
|
||||
"VALUES (2, 'Orga', NULL, '0', 'video', '1', '1245', 'http://www.baidu.com', \n",
|
||||
"NULL, 0, '0', 'xtl', '2026-01-14 17:04:49', 0, 'xtl', 'xtl', \n",
|
||||
"'2026-01-14 17:05:10', 'xtl', 0);\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"INSERT INTO `sys_custom_open_page` \n",
|
||||
"(`parent_id`, `name`, `description`, `page_level`, `biz_type`, `page_type`, \n",
|
||||
"`section_code`, `page_path`, `page_url`, `dept_id`, `del_flag`, `create_by`, \n",
|
||||
"`create_time`, `create_person_id`, `create_person_name`, `update_by`, \n",
|
||||
"`update_time`, `update_person_name`, `update_person_id`) \n",
|
||||
"VALUES (2, 'Ergo', NULL, '0', 'video', '1', '1245', 'http://www.baidu.com', \n",
|
||||
"NULL, 0, '0', 'xtl', '2026-01-14 17:04:49', 0, 'xtl', 'xtl', \n",
|
||||
"'2026-01-14 17:05:10', 'xtl', 0);\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"INSERT INTO `sys_custom_open_page` \n",
|
||||
"(`parent_id`, `name`, `description`, `page_level`, `biz_type`, `page_type`, \n",
|
||||
"`section_code`, `page_path`, `page_url`, `dept_id`, `del_flag`, `create_by`, \n",
|
||||
"`create_time`, `create_person_id`, `create_person_name`, `update_by`, \n",
|
||||
"`update_time`, `update_person_name`, `update_person_id`) \n",
|
||||
"VALUES (2, 'Clon', NULL, '0', 'video', '1', '1245', 'http://www.baidu.com', \n",
|
||||
"NULL, 0, '0', 'xtl', '2026-01-14 17:04:49', 0, 'xtl', 'xtl', \n",
|
||||
"'2026-01-14 17:05:10', 'xtl', 0);\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"INSERT INTO `sys_custom_open_page` \n",
|
||||
"(`parent_id`, `name`, `description`, `page_level`, `biz_type`, `page_type`, \n",
|
||||
"`section_code`, `page_path`, `page_url`, `dept_id`, `del_flag`, `create_by`, \n",
|
||||
"`create_time`, `create_person_id`, `create_person_name`, `update_by`, \n",
|
||||
"`update_time`, `update_person_name`, `update_person_id`) \n",
|
||||
"VALUES (2, 'Pola', NULL, '0', 'video', '1', '1245', 'http://www.baidu.com', \n",
|
||||
"NULL, 0, '0', 'xtl', '2026-01-14 17:04:49', 0, 'xtl', 'xtl', \n",
|
||||
"'2026-01-14 17:05:10', 'xtl', 0);\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"INSERT INTO `sys_custom_open_page` \n",
|
||||
"(`parent_id`, `name`, `description`, `page_level`, `biz_type`, `page_type`, \n",
|
||||
"`section_code`, `page_path`, `page_url`, `dept_id`, `del_flag`, `create_by`, \n",
|
||||
"`create_time`, `create_person_id`, `create_person_name`, `update_by`, \n",
|
||||
"`update_time`, `update_person_name`, `update_person_id`) \n",
|
||||
"VALUES (1, 'Opti', NULL, '0', 'video', '1', '1245', 'http://www.baidu.com', \n",
|
||||
"NULL, 0, '0', 'xtl', '2026-01-14 17:04:49', 0, 'xtl', 'xtl', \n",
|
||||
"'2026-01-14 17:05:10', 'xtl', 0);\n",
|
||||
"\n",
|
||||
"10条数据插入成功!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"\n",
|
||||
"\n",
|
||||
"# 3. 循环生成10条数据并插入\n",
|
||||
"for _ in range(10):\n",
|
||||
" # 生成随机parent_id(1-4)\n",
|
||||
" random_parent_id = random.randint(1, 4)\n",
|
||||
" # 生成随机名称(faker的word/name方法,这里用catch_phrase生成更贴合“页面名称”的随机词)\n",
|
||||
" random_name = fake.catch_phrase()[:4] # 限制长度避免超出字段长度\n",
|
||||
" sql = insert_sql.format(random_parent_id, random_name)\n",
|
||||
" insert_sql = f\"\"\"\n",
|
||||
"INSERT INTO `sys_custom_open_page` \n",
|
||||
"(`parent_id`, `name`, `description`, `page_level`, `biz_type`, `page_type`, \n",
|
||||
"`section_code`, `page_path`, `page_url`, `dept_id`, `del_flag`, `create_by`, \n",
|
||||
"`create_time`, `create_person_id`, `create_person_name`, `update_by`, \n",
|
||||
"`update_time`, `update_person_name`, `update_person_id`) \n",
|
||||
"VALUES ({random_parent_id}, '{random_name}', NULL, '0', 'video', '1', '1245', 'http://www.baidu.com', \n",
|
||||
"NULL, 0, '0', 'xtl', '2026-01-14 17:04:49', 0, 'xtl', 'xtl', \n",
|
||||
"'2026-01-14 17:05:10', 'xtl', 0);\n",
|
||||
"\"\"\"\n",
|
||||
" print(insert_sql)\n",
|
||||
" # 执行插入\n",
|
||||
" # cursor.execute(insert_sql, (random_parent_id, random_name))\n",
|
||||
"\n",
|
||||
"# 4. 提交事务(必须提交才会写入数据库)\n",
|
||||
"# connection.commit()\n",
|
||||
"print(\"10条数据插入成功!\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "5cb7f98e",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"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,315 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "b82fd271",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pymysql\n",
|
||||
"import snowflake\n",
|
||||
"from faker import Faker\n",
|
||||
"import random\n",
|
||||
"import datetime\n",
|
||||
"fake = Faker('zh_CN')\n",
|
||||
"import random\n",
|
||||
"# 创建数据库连接\n",
|
||||
"connection = pymysql.connect(\n",
|
||||
"host='192.168.0.244',\n",
|
||||
"port=3306,\n",
|
||||
"user='root',\n",
|
||||
"password='Abcd@123456',\n",
|
||||
"database='hongxx_video',\n",
|
||||
"charset='utf8'\n",
|
||||
")\n",
|
||||
"# 创建游标对象\n",
|
||||
"cursor = connection.cursor()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "759c550a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"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"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"id": "4564d4e7",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "IntegrityError",
|
||||
"evalue": "(1062, \"Duplicate entry '301' for key 'sys_grade.PRIMARY'\")",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[1;31mIntegrityError\u001b[0m Traceback (most recent call last)",
|
||||
"Cell \u001b[1;32mIn[10], line 12\u001b[0m\n\u001b[0;32m 10\u001b[0m stage_id \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m1\u001b[39m\n\u001b[0;32m 11\u001b[0m sql\u001b[38;5;241m=\u001b[39m\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mINSERT INTO `hongxx_video`.`sys_grade` (`id`, `grade_name`, `sort`, `status`, `create_time`, `update_time`, `dept_id`, `stage_id`) VALUES (\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mid\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m, \u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mgrade_name\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m, \u001b[39m\u001b[38;5;132;01m{\u001b[39;00msort\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m, \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mstatus\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m, \u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mcreate_time\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m, \u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mupdate_time\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m, \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mdept_id\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m, \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mstage_id\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m)\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m---> 12\u001b[0m cursor\u001b[38;5;241m.\u001b[39mexecute(sql)\n",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\pymysql\\cursors.py:153\u001b[0m, in \u001b[0;36mCursor.execute\u001b[1;34m(self, query, args)\u001b[0m\n\u001b[0;32m 149\u001b[0m \u001b[38;5;28;01mpass\u001b[39;00m\n\u001b[0;32m 151\u001b[0m query \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mmogrify(query, args)\n\u001b[1;32m--> 153\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_query(query)\n\u001b[0;32m 154\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_executed \u001b[38;5;241m=\u001b[39m query\n\u001b[0;32m 155\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m result\n",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\pymysql\\cursors.py:322\u001b[0m, in \u001b[0;36mCursor._query\u001b[1;34m(self, q)\u001b[0m\n\u001b[0;32m 320\u001b[0m conn \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_get_db()\n\u001b[0;32m 321\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_clear_result()\n\u001b[1;32m--> 322\u001b[0m conn\u001b[38;5;241m.\u001b[39mquery(q)\n\u001b[0;32m 323\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_do_get_result()\n\u001b[0;32m 324\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mrowcount\n",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\pymysql\\connections.py:563\u001b[0m, in \u001b[0;36mConnection.query\u001b[1;34m(self, sql, unbuffered)\u001b[0m\n\u001b[0;32m 561\u001b[0m sql \u001b[38;5;241m=\u001b[39m sql\u001b[38;5;241m.\u001b[39mencode(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mencoding, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msurrogateescape\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 562\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_execute_command(COMMAND\u001b[38;5;241m.\u001b[39mCOM_QUERY, sql)\n\u001b[1;32m--> 563\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_affected_rows \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_read_query_result(unbuffered\u001b[38;5;241m=\u001b[39munbuffered)\n\u001b[0;32m 564\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_affected_rows\n",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\pymysql\\connections.py:825\u001b[0m, in \u001b[0;36mConnection._read_query_result\u001b[1;34m(self, unbuffered)\u001b[0m\n\u001b[0;32m 823\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 824\u001b[0m result \u001b[38;5;241m=\u001b[39m MySQLResult(\u001b[38;5;28mself\u001b[39m)\n\u001b[1;32m--> 825\u001b[0m result\u001b[38;5;241m.\u001b[39mread()\n\u001b[0;32m 826\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_result \u001b[38;5;241m=\u001b[39m result\n\u001b[0;32m 827\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m result\u001b[38;5;241m.\u001b[39mserver_status \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\pymysql\\connections.py:1199\u001b[0m, in \u001b[0;36mMySQLResult.read\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 1197\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mread\u001b[39m(\u001b[38;5;28mself\u001b[39m):\n\u001b[0;32m 1198\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m-> 1199\u001b[0m first_packet \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mconnection\u001b[38;5;241m.\u001b[39m_read_packet()\n\u001b[0;32m 1201\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m first_packet\u001b[38;5;241m.\u001b[39mis_ok_packet():\n\u001b[0;32m 1202\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_read_ok_packet(first_packet)\n",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\pymysql\\connections.py:775\u001b[0m, in \u001b[0;36mConnection._read_packet\u001b[1;34m(self, packet_type)\u001b[0m\n\u001b[0;32m 773\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_result \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_result\u001b[38;5;241m.\u001b[39munbuffered_active \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m:\n\u001b[0;32m 774\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_result\u001b[38;5;241m.\u001b[39munbuffered_active \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mFalse\u001b[39;00m\n\u001b[1;32m--> 775\u001b[0m packet\u001b[38;5;241m.\u001b[39mraise_for_error()\n\u001b[0;32m 776\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m packet\n",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\pymysql\\protocol.py:219\u001b[0m, in \u001b[0;36mMysqlPacket.raise_for_error\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 217\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m DEBUG:\n\u001b[0;32m 218\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124merrno =\u001b[39m\u001b[38;5;124m\"\u001b[39m, errno)\n\u001b[1;32m--> 219\u001b[0m err\u001b[38;5;241m.\u001b[39mraise_mysql_exception(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_data)\n",
|
||||
"File \u001b[1;32md:\\Anaconda3\\Lib\\site-packages\\pymysql\\err.py:150\u001b[0m, in \u001b[0;36mraise_mysql_exception\u001b[1;34m(data)\u001b[0m\n\u001b[0;32m 148\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m errorclass \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m 149\u001b[0m errorclass \u001b[38;5;241m=\u001b[39m InternalError \u001b[38;5;28;01mif\u001b[39;00m errno \u001b[38;5;241m<\u001b[39m \u001b[38;5;241m1000\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m OperationalError\n\u001b[1;32m--> 150\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m errorclass(errno, errval)\n",
|
||||
"\u001b[1;31mIntegrityError\u001b[0m: (1062, \"Duplicate entry '301' for key 'sys_grade.PRIMARY'\")"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import datetime\n",
|
||||
"for i in range(3):\n",
|
||||
" id = 301 + i\n",
|
||||
" grade_name = f'高{i+1}'\n",
|
||||
" sort = i+1\n",
|
||||
" status = 1\n",
|
||||
" create_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')\n",
|
||||
" update_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')\n",
|
||||
" dept_id = 0\n",
|
||||
" stage_id = 1\n",
|
||||
" sql=f'INSERT INTO `hongxx_video`.`sys_grade` (`id`, `grade_name`, `sort`, `status`, `create_time`, `update_time`, `dept_id`, `stage_id`) VALUES ({id}, \"{grade_name}\", {sort}, {status}, \"{create_time}\", \"{update_time}\", {dept_id}, {stage_id})'\n",
|
||||
" cursor.execute(sql)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "0318e673",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"result = cursor.fetchall()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "143d5c55",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"connection.commit()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"id": "11beb02c",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import random\n",
|
||||
"subject = [ \"语文\", \"数学\", \"英语\", \"物理\", \"化学\", \"生物\", \n",
|
||||
" \"历史\", \"地理\", \"政治\", \"道德与法治\", \"科学\", \n",
|
||||
" \"音乐\", \"美术\", \"体育\", \"信息技术\", \"通用技术\",\n",
|
||||
" \"劳动技术\", \"综合实践活动\", \"心理健康\", \"书法\"]\n",
|
||||
"grades = [101,102,103,104,105,106,201,202,203,301,302,303]\n",
|
||||
"for i in range(20):\n",
|
||||
" grade_id = random.choice(grades)\n",
|
||||
" subject_name = random.choice(subject)\n",
|
||||
" sql = f'INSERT INTO `hongxx_video`.`sys_subject` ( `subject_name`, `sort`, `status`, `create_time`, `update_time`, `dept_id`, `grade_id`) VALUES ( \"{subject_name}\", {i}, 1, \"2025-12-23 11:24:38\", \"2025-12-23 11:24:41\", 0, {grade_id});' \n",
|
||||
" cursor.execute(sql)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "17b02aa1",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"((1,), (2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,), (11,), (12,), (13,), (14,), (15,), (16,), (17,), (18,), (19,), (20,), (21,))\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"sql = \"select id from sys_subject\"\n",
|
||||
"cursor.execute(sql)\n",
|
||||
"rows = cursor.fetchall()\n",
|
||||
"print(rows)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "cc7e1348",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"courses = [\n",
|
||||
" # 编程与计算机科学\n",
|
||||
" \"Python编程入门\", \"Python高级编程\", \"Python数据分析\", \"Python爬虫开发\", \"Python机器学习\",\n",
|
||||
" \"Python深度学习\", \"Python自动化办公\", \"Python网络编程\", \"Python游戏开发\", \"Python图像处理\",\n",
|
||||
" \"Python自然语言处理\", \"Python金融分析\", \"Python量化交易\", \"Python测试开发\", \"Python Web开发\",\n",
|
||||
" \"Java基础课程\", \"Java企业级开发\", \"Java并发编程\", \"Java微服务架构\", \"Java性能优化\",\n",
|
||||
" \"C++从入门到精通\", \"C++游戏开发\", \"C++高性能计算\", \"Go语言编程\", \"Go微服务开发\",\n",
|
||||
" \"Rust系统编程\", \"Swift移动开发\", \"Kotlin安卓开发\", \"JavaScript基础\", \"TypeScript进阶\",\n",
|
||||
" \"Vue.js前端开发\", \"React全栈开发\", \"Node.js后端开发\", \"Angular企业级应用\", \"微信小程序开发\",\n",
|
||||
" \n",
|
||||
" # 数据科学与人工智能\n",
|
||||
" \"数据分析基础\", \"数据可视化\", \"数据挖掘\", \"大数据技术\", \"Hadoop生态圈\",\n",
|
||||
" \"Spark实时计算\", \"SQL与数据库\", \"NoSQL数据库\", \"数据仓库设计\", \"数据治理\",\n",
|
||||
" \"机器学习基础\", \"深度学习原理\", \"计算机视觉\", \"语音识别技术\", \"推荐系统\",\n",
|
||||
" \"强化学习\", \"生成式AI\", \"大语言模型应用\", \"AIGC创作\", \"AI绘画\",\n",
|
||||
" \"统计学基础\", \"概率论应用\", \"线性代数与AI\", \"微积分在AI中的应用\", \"优化算法\",\n",
|
||||
" \n",
|
||||
" # 前端与移动开发\n",
|
||||
" \"HTML5与CSS3\", \"响应式网页设计\", \"前端工程化\", \"Webpack配置\", \"前端性能优化\",\n",
|
||||
" \"React Native开发\", \"Flutter跨平台开发\", \"iOS原生开发\", \"Android原生开发\", \"鸿蒙应用开发\",\n",
|
||||
" \"Electron桌面应用\", \"小程序云开发\", \"前端安全\", \"PWA渐进式Web应用\", \"Three.js 3D开发\",\n",
|
||||
" \n",
|
||||
" # 后端与云计算\n",
|
||||
" \"Linux系统管理\", \"Shell脚本编程\", \"Docker容器技术\", \"Kubernetes编排\", \"DevOps实践\",\n",
|
||||
" \"CI/CD流水线\", \"微服务架构\", \"分布式系统\", \"高并发系统设计\", \"系统架构师\",\n",
|
||||
" \"AWS云计算\", \"Azure云服务\", \"阿里云实战\", \"腾讯云应用\", \"云原生架构\",\n",
|
||||
" \"Nginx配置优化\", \"Redis缓存技术\", \"消息队列\", \"Elasticsearch搜索\", \"MySQL优化\",\n",
|
||||
" \n",
|
||||
" # 网络安全\n",
|
||||
" \"网络安全基础\", \"渗透测试入门\", \"Web安全攻防\", \"漏洞挖掘与利用\", \"逆向工程\",\n",
|
||||
" \"密码学原理\", \"安全开发规范\", \"应急响应\", \"安全合规\", \"红蓝对抗\",\n",
|
||||
" \n",
|
||||
" # 学术与教育\n",
|
||||
" \"高等数学\", \"线性代数\", \"概率论与数理统计\", \"离散数学\", \"复变函数\",\n",
|
||||
" \"大学物理\", \"理论力学\", \"电动力学\", \"量子力学\", \"热力学与统计物理\",\n",
|
||||
" \"普通化学\", \"有机化学\", \"分析化学\", \"物理化学\", \"结构化学\",\n",
|
||||
" \"细胞生物学\", \"分子生物学\", \"遗传学\", \"生物化学\", \"生态学\",\n",
|
||||
" \"中国文学史\", \"外国文学\", \"比较文学\", \"古代汉语\", \"现代汉语\",\n",
|
||||
" \"世界历史\", \"中国通史\", \"考古学概论\", \"文物鉴赏\", \"博物馆学\",\n",
|
||||
" \n",
|
||||
" # 语言学习\n",
|
||||
" \"大学英语四级\", \"大学英语六级\", \"托福备考\", \"雅思冲刺\", \"GRE强化\",\n",
|
||||
" \"日语入门\", \"日语N1\", \"韩语基础\", \"法语初级\", \"德语入门\",\n",
|
||||
" \"西班牙语A1\", \"俄语基础\", \"阿拉伯语入门\", \"葡萄牙语\", \"意大利语\",\n",
|
||||
" \"商务英语\", \"学术英语写作\", \"英语口语强化\", \"英语演讲与辩论\", \"翻译技巧\",\n",
|
||||
" \n",
|
||||
" # 艺术与设计\n",
|
||||
" \"素描基础\", \"色彩构成\", \"油画技法\", \"国画山水\", \"书法艺术\",\n",
|
||||
" \"平面设计\", \"UI设计基础\", \"UX用户体验\", \"交互设计\", \"动效设计\",\n",
|
||||
" \"摄影基础\", \"人像摄影\", \"风光摄影\", \"影视后期\", \"视频剪辑\",\n",
|
||||
" \"音乐理论\", \"钢琴入门\", \"吉他弹唱\", \"声乐训练\", \"作曲基础\",\n",
|
||||
" \"舞蹈基础\", \"芭蕾舞\", \"现代舞\", \"街舞\", \"民族舞\",\n",
|
||||
" \n",
|
||||
" # 商业与金融\n",
|
||||
" \"经济学原理\", \"微观经济学\", \"宏观经济学\", \"计量经济学\", \"产业经济学\",\n",
|
||||
" \"金融学基础\", \"投资学\", \"公司金融\", \"金融市场\", \"行为金融学\",\n",
|
||||
" \"会计学原理\", \"财务管理\", \"审计学\", \"税务筹划\", \"成本会计\",\n",
|
||||
" \"管理学原理\", \"市场营销\", \"人力资源管理\", \"战略管理\", \"组织行为学\",\n",
|
||||
" \"创业基础\", \"商业计划书撰写\", \"风险投资\", \"商业模式创新\", \"企业融资\",\n",
|
||||
" \n",
|
||||
" # 职业技能\n",
|
||||
" \"Office办公软件\", \"Excel高级应用\", \"PPT设计技巧\", \"Word排版艺术\", \"项目管理\",\n",
|
||||
" \"时间管理\", \"有效沟通\", \"团队协作\", \"领导力培养\", \"演讲与表达\",\n",
|
||||
" \"商务礼仪\", \"职场英语\", \"简历制作\", \"面试技巧\", \"职业规划\",\n",
|
||||
" \n",
|
||||
" # 生活技能与兴趣爱好\n",
|
||||
" \"烹饪基础\", \"中式烹饪\", \"西点制作\", \"咖啡拉花\", \"茶艺品鉴\",\n",
|
||||
" \"葡萄酒鉴赏\", \"调酒艺术\", \"花艺设计\", \"园艺种植\", \"宠物饲养\",\n",
|
||||
" \"健身训练\", \"瑜伽入门\", \"普拉提\", \"拳击训练\", \"游泳技巧\",\n",
|
||||
" \"篮球基础\", \"足球训练\", \"网球入门\", \"羽毛球\", \"乒乓球\",\n",
|
||||
" \"围棋入门\", \"国际象棋\", \"桥牌\", \"德州扑克\", \"魔术技巧\",\n",
|
||||
" \n",
|
||||
" # 考试与认证\n",
|
||||
" \"公务员考试行测\", \"公务员考试申论\", \"事业单位考试\", \"教师资格证考试\", \"司法考试\",\n",
|
||||
" \"注册会计师CPA\", \"特许金融分析师CFA\", \"金融风险管理师FRM\", \"项目管理PMP\", \"信息系统项目管理师\",\n",
|
||||
" \n",
|
||||
" # 新兴技术\n",
|
||||
" \"区块链技术\", \"智能合约开发\", \"Web3.0应用\", \"元宇宙概念\", \"数字藏品\",\n",
|
||||
" \"物联网技术\", \"嵌入式开发\", \"机器人编程\", \"无人机控制\", \"3D打印技术\",\n",
|
||||
" \"自动驾驶技术\", \"新能源汽车\", \"虚拟现实VR\", \"增强现实AR\", \"混合现实MR\",\n",
|
||||
" \n",
|
||||
" # 其他\n",
|
||||
" \"逻辑思维训练\", \"批判性思维\", \"创意写作\", \"公共演讲\", \"辩论技巧\",\n",
|
||||
" \"儿童编程启蒙\", \"青少年机器人\", \"老年智能手机\", \"家庭教育\", \"心理学基础\",\n",
|
||||
" \"营养学基础\", \"中医养生\", \"急救知识\", \"防灾减灾\", \"野外生存\"\n",
|
||||
"]\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "55828fd0",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for i in range(200):\n",
|
||||
" course = random.choice(courses)\n",
|
||||
" subject_id = random.choice(range(1,21))\n",
|
||||
" now = datetime.datetime.now().strftime(\"%Y-%m-%d %H:%M:%S\")\n",
|
||||
" sql = f'INSERT INTO `hongxx_video`.`video_chapter` ( `chapter_name`, `parent_id`, `teacher_id`, `sort`, `status`, `create_time`, `update_time`, `dept_id`, `subject_id`) VALUES ( \"{course}\", 0, 0, 0, 1, \"{now}\", \"{now}\", 0, {subject_id});'\n",
|
||||
" cursor.execute(sql)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "d5823c86",
|
||||
"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>。"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"connection.commit()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "b717043a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"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,124 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "b82fd271",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pymysql\n",
|
||||
"import snowflake\n",
|
||||
"from faker import Faker\n",
|
||||
"fake = Faker('zh_CN')\n",
|
||||
"import random\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",
|
||||
"# 创建游标对象\n",
|
||||
"cursor = connection.cursor()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "759c550a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"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"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"id": "977b832d",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"sql='select * from class_attend limit 0,10'"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"id": "0318e673",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"cursor.execute(sql)\n",
|
||||
"result = cursor.fetchall()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "7af746d4",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"result = create_table(cursor,result)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"id": "5bb61d61",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"sql='''\n",
|
||||
"UPDATE class_attend \n",
|
||||
"SET \n",
|
||||
" class_s_time = DATE_ADD(class_s_time, INTERVAL 28 DAY),\n",
|
||||
" class_e_time = DATE_ADD(class_e_time, INTERVAL 28 DAY),\n",
|
||||
" start_time = DATE_ADD(start_time, INTERVAL 28 DAY),\n",
|
||||
" end_time = DATE_ADD(end_time, INTERVAL 28 DAY),\n",
|
||||
" attend_date = DATE_ADD(attend_date, INTERVAL 28 DAY),\n",
|
||||
" class_s_times = DATE_ADD(class_s_times, INTERVAL 28 DAY),\n",
|
||||
" class_e_times = DATE_ADD(class_e_times, INTERVAL 28 DAY);\n",
|
||||
"'''\n",
|
||||
"cursor.execute(sql)\n",
|
||||
"connection.commit()"
|
||||
]
|
||||
}
|
||||
],
|
||||
"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,546 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 41,
|
||||
"id": "66d26142",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pymysql\n",
|
||||
"import pandas as pd\n",
|
||||
"import snowflake\n",
|
||||
"import random"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 42,
|
||||
"id": "7538343f",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"\n",
|
||||
"# 创建数据库连接\n",
|
||||
"connection = pymysql.connect(\n",
|
||||
"host='www.hxzhxy.cn',\n",
|
||||
"user='root',\n",
|
||||
"password='@HXYD1109mysql',\n",
|
||||
"database='school_server',\n",
|
||||
"charset='utf8'\n",
|
||||
")\n",
|
||||
"# 创建游标对象\n",
|
||||
"cursor = connection.cursor()\n",
|
||||
"sql=\"select id,stu_name from student where team_id=19\"\n",
|
||||
"cursor.execute(sql)\n",
|
||||
"result=cursor.fetchall()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 43,
|
||||
"id": "8c88cbf4",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"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"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 44,
|
||||
"id": "11b4b922",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"table = create_table(cursor,result)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 45,
|
||||
"id": "b0b8f2a4",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"name2id = {item[\"stu_name\"]:item[\"id\"] for item in table}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 46,
|
||||
"id": "c7b2c510",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"4675"
|
||||
]
|
||||
},
|
||||
"execution_count": 46,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"len(table)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 47,
|
||||
"id": "dcd74d67",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"sql1 = \"select * from application_info where application_id=95\"\n",
|
||||
"cursor.execute(sql1)\n",
|
||||
"result=cursor.fetchall()\n",
|
||||
"table_app = create_table(cursor,result)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "d305d2bd",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 48,
|
||||
"id": "8f20375f",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"df = pd.DataFrame(table_app)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 49,
|
||||
"id": "93403945",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"Index(['id', 'application_id', 'user_id', 'user_type', 'form_content',\n",
|
||||
" 'submit_time', 'team_id', 'user_data', 'origin_form'],\n",
|
||||
" dtype='object')"
|
||||
]
|
||||
},
|
||||
"execution_count": 49,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"df.columns"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 50,
|
||||
"id": "88caddc9",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>id</th>\n",
|
||||
" <th>application_id</th>\n",
|
||||
" <th>user_id</th>\n",
|
||||
" <th>user_type</th>\n",
|
||||
" <th>form_content</th>\n",
|
||||
" <th>submit_time</th>\n",
|
||||
" <th>team_id</th>\n",
|
||||
" <th>user_data</th>\n",
|
||||
" <th>origin_form</th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>0</th>\n",
|
||||
" <td>4489</td>\n",
|
||||
" <td>95</td>\n",
|
||||
" <td>10028</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>{\"姓名\": \"唐琪沂\", \"学号\": \"20250423\", \"是否经过监护人和学生本人共...</td>\n",
|
||||
" <td>2026-02-24 08:01:44</td>\n",
|
||||
" <td>19</td>\n",
|
||||
" <td>None</td>\n",
|
||||
" <td>{\"input82274\": \"唐琪沂\", \"input89185\": \"20250423\"...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>1</th>\n",
|
||||
" <td>4490</td>\n",
|
||||
" <td>95</td>\n",
|
||||
" <td>8461</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>{\"姓名\": \"瞿子渊\", \"学号\": \"20240533\", \"是否经过监护人和学生本人共...</td>\n",
|
||||
" <td>2026-02-24 08:01:47</td>\n",
|
||||
" <td>19</td>\n",
|
||||
" <td>None</td>\n",
|
||||
" <td>{\"input82274\": \"瞿子渊\", \"input89185\": \"20240533\"...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>2</th>\n",
|
||||
" <td>4491</td>\n",
|
||||
" <td>95</td>\n",
|
||||
" <td>6738</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>{\"姓名\": \"陈梓心\", \"学号\": \"26010065\", \"是否经过监护人和学生本人共...</td>\n",
|
||||
" <td>2026-02-24 08:01:51</td>\n",
|
||||
" <td>19</td>\n",
|
||||
" <td>None</td>\n",
|
||||
" <td>{\"input82274\": \"陈梓心\", \"input89185\": \"26010065\"...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>3</th>\n",
|
||||
" <td>4492</td>\n",
|
||||
" <td>95</td>\n",
|
||||
" <td>7644</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>{\"姓名\": \"刘斯馨\", \"学号\": \"20240402\", \"是否经过监护人和学生本人共...</td>\n",
|
||||
" <td>2026-02-24 18:03:22</td>\n",
|
||||
" <td>19</td>\n",
|
||||
" <td>None</td>\n",
|
||||
" <td>{\"input82274\": \"刘斯馨\", \"input89185\": \"20240402\"...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>4</th>\n",
|
||||
" <td>4493</td>\n",
|
||||
" <td>95</td>\n",
|
||||
" <td>8465</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>{\"姓名\": \"宋振豪\", \"学号\": \"20240576\", \"是否经过监护人和学生本人共...</td>\n",
|
||||
" <td>2026-02-24 08:02:47</td>\n",
|
||||
" <td>19</td>\n",
|
||||
" <td>None</td>\n",
|
||||
" <td>{\"input82274\": \"宋振豪\", \"input89185\": \"20240576\"...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>...</th>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>796</th>\n",
|
||||
" <td>5319</td>\n",
|
||||
" <td>95</td>\n",
|
||||
" <td>7856</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>{\"姓名\": \"吴承轩\", \"学号\": \"20240705\", \"是否经过监护人和学生本人共...</td>\n",
|
||||
" <td>2026-02-25 13:24:28</td>\n",
|
||||
" <td>19</td>\n",
|
||||
" <td>None</td>\n",
|
||||
" <td>{\"input82274\": \"吴承轩\", \"input89185\": \"20240705\"...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>797</th>\n",
|
||||
" <td>5320</td>\n",
|
||||
" <td>95</td>\n",
|
||||
" <td>6443</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>{\"姓名\": \"姚欣怡\", \"学号\": \"23010643\", \"是否经过监护人和学生本人共...</td>\n",
|
||||
" <td>2026-02-25 13:33:48</td>\n",
|
||||
" <td>19</td>\n",
|
||||
" <td>None</td>\n",
|
||||
" <td>{\"input82274\": \"姚欣怡\", \"input89185\": \"23010643\"...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>798</th>\n",
|
||||
" <td>5321</td>\n",
|
||||
" <td>95</td>\n",
|
||||
" <td>10063</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>{\"姓名\": \"王韵佳\", \"学号\": \"20250479\", \"是否经过监护人和学生本人共...</td>\n",
|
||||
" <td>2026-02-25 13:44:20</td>\n",
|
||||
" <td>19</td>\n",
|
||||
" <td>None</td>\n",
|
||||
" <td>{\"input82274\": \"王韵佳\", \"input89185\": \"20250479\"...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>799</th>\n",
|
||||
" <td>5322</td>\n",
|
||||
" <td>95</td>\n",
|
||||
" <td>6593</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>{\"姓名\": \"蔡玉汝\", \"学号\": \"23010007\", \"是否经过监护人和学生本人共...</td>\n",
|
||||
" <td>2026-02-25 13:46:56</td>\n",
|
||||
" <td>19</td>\n",
|
||||
" <td>None</td>\n",
|
||||
" <td>{\"input82274\": \"蔡玉汝\", \"input89185\": \"23010007\"...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>800</th>\n",
|
||||
" <td>5323</td>\n",
|
||||
" <td>95</td>\n",
|
||||
" <td>6814</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>{\"姓名\": \"马滢然\", \"学号\": \"23010360\", \"是否经过监护人和学生本人共...</td>\n",
|
||||
" <td>2026-02-25 13:59:44</td>\n",
|
||||
" <td>19</td>\n",
|
||||
" <td>None</td>\n",
|
||||
" <td>{\"input82274\": \"马滢然\", \"input89185\": \"23010360\"...</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"<p>801 rows × 9 columns</p>\n",
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
" id application_id user_id user_type \\\n",
|
||||
"0 4489 95 10028 0 \n",
|
||||
"1 4490 95 8461 0 \n",
|
||||
"2 4491 95 6738 0 \n",
|
||||
"3 4492 95 7644 0 \n",
|
||||
"4 4493 95 8465 0 \n",
|
||||
".. ... ... ... ... \n",
|
||||
"796 5319 95 7856 0 \n",
|
||||
"797 5320 95 6443 0 \n",
|
||||
"798 5321 95 10063 0 \n",
|
||||
"799 5322 95 6593 0 \n",
|
||||
"800 5323 95 6814 0 \n",
|
||||
"\n",
|
||||
" form_content submit_time \\\n",
|
||||
"0 {\"姓名\": \"唐琪沂\", \"学号\": \"20250423\", \"是否经过监护人和学生本人共... 2026-02-24 08:01:44 \n",
|
||||
"1 {\"姓名\": \"瞿子渊\", \"学号\": \"20240533\", \"是否经过监护人和学生本人共... 2026-02-24 08:01:47 \n",
|
||||
"2 {\"姓名\": \"陈梓心\", \"学号\": \"26010065\", \"是否经过监护人和学生本人共... 2026-02-24 08:01:51 \n",
|
||||
"3 {\"姓名\": \"刘斯馨\", \"学号\": \"20240402\", \"是否经过监护人和学生本人共... 2026-02-24 18:03:22 \n",
|
||||
"4 {\"姓名\": \"宋振豪\", \"学号\": \"20240576\", \"是否经过监护人和学生本人共... 2026-02-24 08:02:47 \n",
|
||||
".. ... ... \n",
|
||||
"796 {\"姓名\": \"吴承轩\", \"学号\": \"20240705\", \"是否经过监护人和学生本人共... 2026-02-25 13:24:28 \n",
|
||||
"797 {\"姓名\": \"姚欣怡\", \"学号\": \"23010643\", \"是否经过监护人和学生本人共... 2026-02-25 13:33:48 \n",
|
||||
"798 {\"姓名\": \"王韵佳\", \"学号\": \"20250479\", \"是否经过监护人和学生本人共... 2026-02-25 13:44:20 \n",
|
||||
"799 {\"姓名\": \"蔡玉汝\", \"学号\": \"23010007\", \"是否经过监护人和学生本人共... 2026-02-25 13:46:56 \n",
|
||||
"800 {\"姓名\": \"马滢然\", \"学号\": \"23010360\", \"是否经过监护人和学生本人共... 2026-02-25 13:59:44 \n",
|
||||
"\n",
|
||||
" team_id user_data origin_form \n",
|
||||
"0 19 None {\"input82274\": \"唐琪沂\", \"input89185\": \"20250423\"... \n",
|
||||
"1 19 None {\"input82274\": \"瞿子渊\", \"input89185\": \"20240533\"... \n",
|
||||
"2 19 None {\"input82274\": \"陈梓心\", \"input89185\": \"26010065\"... \n",
|
||||
"3 19 None {\"input82274\": \"刘斯馨\", \"input89185\": \"20240402\"... \n",
|
||||
"4 19 None {\"input82274\": \"宋振豪\", \"input89185\": \"20240576\"... \n",
|
||||
".. ... ... ... \n",
|
||||
"796 19 None {\"input82274\": \"吴承轩\", \"input89185\": \"20240705\"... \n",
|
||||
"797 19 None {\"input82274\": \"姚欣怡\", \"input89185\": \"23010643\"... \n",
|
||||
"798 19 None {\"input82274\": \"王韵佳\", \"input89185\": \"20250479\"... \n",
|
||||
"799 19 None {\"input82274\": \"蔡玉汝\", \"input89185\": \"23010007\"... \n",
|
||||
"800 19 None {\"input82274\": \"马滢然\", \"input89185\": \"23010360\"... \n",
|
||||
"\n",
|
||||
"[801 rows x 9 columns]"
|
||||
]
|
||||
},
|
||||
"execution_count": 50,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"df"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 51,
|
||||
"id": "cf9f0877",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"id1 = df[df.duplicated(subset=['user_id'],keep='last')]['id']\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 52,
|
||||
"id": "065978e4",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"Series([], Name: id, dtype: int64)"
|
||||
]
|
||||
},
|
||||
"execution_count": 52,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"id1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 33,
|
||||
"id": "3f2dce88",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for item in id1.tolist():\n",
|
||||
" sql = f'delete from application_info where id = {item}'\n",
|
||||
" cursor.execute(sql)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 34,
|
||||
"id": "e325888a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"connection.commit()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"id": "4c3c2181",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"sql1 = \"select * from application_info where application_id=95\"\n",
|
||||
"cursor.execute(sql1)\n",
|
||||
"result=cursor.fetchall()\n",
|
||||
"table_app = create_table(cursor,result)\n",
|
||||
"\n",
|
||||
" # cursor.execute(sql_update)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"id": "3b6997e2",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"799"
|
||||
]
|
||||
},
|
||||
"execution_count": 18,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"len(table_app)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"id": "e65e7d7f",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"{'id': 4602, 'application_id': 95, 'user_id': 7000, 'user_type': 0, 'form_content': '{\"姓名\": \"导师一班刘梓豪\", \"学号\": \"20250321\", \"是否经过监护人和学生本人共同慎重考虑,自愿申报晚自习\": \"是\"}', 'submit_time': datetime.datetime(2026, 2, 24, 8, 45, 58), 'team_id': 19, 'user_data': None, 'origin_form': '{\"input82274\": \"导师一班刘梓豪\", \"input89185\": \"20250321\", \"radio23109\": 1}'}\n",
|
||||
"{'id': 4740, 'application_id': 95, 'user_id': 3031, 'user_type': 0, 'form_content': '{\"姓名\": \"黄俊英\", \"学号\": \"23010155\", \"是否经过监护人和学生本人共同慎重考虑,自愿申报晚自习\": \"是\"}', 'submit_time': datetime.datetime(2026, 2, 24, 9, 39, 14), 'team_id': 19, 'user_data': None, 'origin_form': '{\"input82274\": \"黄俊英\", \"input89185\": \"23010155\", \"radio23109\": 1}'}\n",
|
||||
"{'id': 4757, 'application_id': 95, 'user_id': 4138, 'user_type': 0, 'form_content': '{\"姓名\": \"李沛霖\", \"学号\": \"20240313\", \"是否经过监护人和学生本人共同慎重考虑,自愿申报晚自习\": \"是\"}', 'submit_time': datetime.datetime(2026, 2, 24, 9, 48, 29), 'team_id': 19, 'user_data': None, 'origin_form': '{\"input82274\": \"李沛霖\", \"input89185\": \"20240313\", \"radio23109\": 1}'}\n",
|
||||
"{'id': 4758, 'application_id': 95, 'user_id': 3620, 'user_type': 0, 'form_content': '{\"姓名\": \"23010047\", \"学号\": \"陈希\", \"是否经过监护人和学生本人共同慎重考虑,自愿申报晚自习\": \"是\"}', 'submit_time': datetime.datetime(2026, 2, 24, 9, 48, 20), 'team_id': 19, 'user_data': None, 'origin_form': '{\"input82274\": \"23010047\", \"input89185\": \"陈希\", \"radio23109\": 1}'}\n",
|
||||
"{'id': 5006, 'application_id': 95, 'user_id': 4269, 'user_type': 0, 'form_content': '{\"姓名\": \"杨凤\", \"学号\": \"20240575\", \"是否经过监护人和学生本人共同慎重考虑,自愿申报晚自习\": \"是\"}', 'submit_time': datetime.datetime(2026, 2, 24, 13, 41, 33), 'team_id': 19, 'user_data': None, 'origin_form': '{\"input82274\": \"杨凤\", \"input89185\": \"20240575\", \"radio23109\": 1}'}\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"for item in table_app:\n",
|
||||
" tem = json.loads(item[\"form_content\"])\n",
|
||||
" name = tem['姓名']\n",
|
||||
" stuid = name2id.get(name,None)\n",
|
||||
" if not stuid:\n",
|
||||
" print(item)\n",
|
||||
" continue\n",
|
||||
" # else:\n",
|
||||
" # sql_update = f'''update application_info set user_id={stuid} where id={item[\"id\"]}'''\n",
|
||||
" # cursor.execute(sql_update)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"id": "0e9ba4bd",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"connection.commit()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "e5ba39d1",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"黄俊英"
|
||||
]
|
||||
}
|
||||
],
|
||||
"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
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
+267
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user