{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7538343f",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pymysql\n",
    "from faker import Faker\n",
    "fake = Faker(\"zh_CN\")\n",
    "import random\n",
    "# 创建数据库连接\n",
    "connection = pymysql.connect(\n",
    "host=\"11.1.1.5\",\n",
    "user=\"root\",\n",
    "password=\"@HXYD1109mysql\",\n",
    "database=\"school_server\",\n",
    "charset=\"utf8\"\n",
    ")\n",
    "# 创建游标对象\n",
    "cursor = connection.cursor()\n",
    "sql=\"select * from robot_knowledge\"\n",
    "cursor.execute(sql)\n",
    "result=cursor.fetchall()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "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": 5,
   "id": "32d77e66",
   "metadata": {},
   "outputs": [],
   "source": [
    "sql=\"\"\"\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学,英语,道德与法治,历史,地理,生物\", available=\"语文总,数学总,英语总,五科总分,道德与法治成绩,历史成绩,生物成绩,地理成绩,十科总分\" WHERE id=1;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"道德与法治,历史\", available=\"道德与法治成绩,历史成绩\" WHERE id=7;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"道德与法治,历史\", available=\"道德与法治成绩,历史成绩\" WHERE id=8;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"A,B,总\" WHERE id=12;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分,班排\" WHERE id=13;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分,班排\" WHERE id=14;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学,英语\", available=\"语文总,数学总,英语总,总分,总排\" WHERE id=15;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分,排名\" WHERE id=16;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分,排名\" WHERE id=17;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分（135）,班排\" WHERE id=18;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分,班排\" WHERE id=19;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分（135）,班排\" WHERE id=20;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分（135）,班排\" WHERE id=21;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"分数\" WHERE id=22;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"分数\" WHERE id=23;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分\" WHERE id=24;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分\" WHERE id=25;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分\" WHERE id=26;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分\" WHERE id=27;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文\", available=\"成绩\" WHERE id=28;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文\", available=\"总分\" WHERE id=29;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分,班排\" WHERE id=30;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分\" WHERE id=34;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"总分,两个班成绩排名\" WHERE id=35;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分（80）\" WHERE id=44;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"总,班排\" WHERE id=47;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,年排\" WHERE id=48;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学,英语,物理\", available=\"语文,数学,英语,物理\" WHERE id=61;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学,英语,物理\", available=\"语文,数学,英语,物理\" WHERE id=62;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学\", available=\"语文,数学\" WHERE id=64;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学,英语\", available=\"语总,数总,英总,三科总\" WHERE id=68;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学,英语,物理,化学\", available=\"语文总分,数学总分,英语总分,物理总分,化学总分,总分\" WHERE id=69;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"总,排名\" WHERE id=70;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学,英语,物理\", available=\"语文总,数学总,英语总,物理总,总分\" WHERE id=72;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学,英语,物理\", available=\"语文总,语文排名,数学总,数学排名,英语总,英语排名,物理总,物理排名\" WHERE id=75;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学,英语\", available=\"语总,语排,数总,数排,英总,英排,三科总,总排\" WHERE id=77;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"总（120分）,本周班排,月考班排\" WHERE id=81;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分,两班排\" WHERE id=92;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"物理\", available=\"物理总,物理排名\" WHERE id=94;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文\", available=\"总分,班级排名\" WHERE id=100;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"英语,班排\" WHERE id=102;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"英语,班排\" WHERE id=103;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分\" WHERE id=104;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分\" WHERE id=105;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文\", available=\"语文\" WHERE id=116;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"本周班排,上周班排\" WHERE id=117;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学,英语,物理,化学,道法,历史\", available=\"语文总分,数学总分,英语总分,物理总分,化学总分,语数外物化总分,道法,历史\" WHERE id=130;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学,英语,物理\", available=\"语文总,数学总,英语总,物理总,四科总分\" WHERE id=140;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"地理,生物\", available=\"生物总分,地理总分\" WHERE id=142;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学,英语,物理\", available=\"语文总,语文排名,数学总,数学排名,英语总,英语排名,物理总,物理排名\" WHERE id=145;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学,英语\", available=\"语总,数总,英总,总分,总排\" WHERE id=146;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学,英语\", available=\"语总,数总,英总,三科总\" WHERE id=147;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"英总,英排\" WHERE id=148;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"英总,英排,班排\" WHERE id=149;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"英总,英排,班排\" WHERE id=150;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"总分\" WHERE id=152;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"分数\" WHERE id=153;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"数学\" WHERE id=154;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分,两班排\" WHERE id=156;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"数学\" WHERE id=157;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"数学\" WHERE id=158;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"数学\" WHERE id=160;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"数学\" WHERE id=162;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"数学\" WHERE id=163;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"数学\" WHERE id=164;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"物理\", available=\"物理总,物理排名\" WHERE id=165;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"总,年级排名,5学段排名\" WHERE id=167;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分110\" WHERE id=174;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分（满分110）\" WHERE id=176;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分（满分110）\" WHERE id=177;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分110\" WHERE id=178;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"英语\" WHERE id=179;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"英语\" WHERE id=180;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"数学\" WHERE id=183;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分,排名\" WHERE id=185;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分,排名\" WHERE id=186;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分,班排\" WHERE id=188;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分,班排\" WHERE id=189;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分\" WHERE id=190;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"总分\" WHERE id=192;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分,两班排\" WHERE id=195;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"排名\" WHERE id=196;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文\", available=\"语文\" WHERE id=202;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文\", available=\"语文\" WHERE id=203;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"数学\" WHERE id=206;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"数学\" WHERE id=207;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"数学,两班排名\" WHERE id=212;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"数学,两班排名\" WHERE id=213;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"分数\" WHERE id=216;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"B卷（满分50）,班排\" WHERE id=217;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"B卷（满分50）,班排\" WHERE id=221;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"分数\" WHERE id=224;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"A卷总分100\" WHERE id=226;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"数学,两班排名\" WHERE id=227;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"A卷（满分100）,班排\" WHERE id=235;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,班排,年排\" WHERE id=236;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,班排,年排\" WHERE id=237;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,班排,年排\" WHERE id=238;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,班排,年排\" WHERE id=239;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩\" WHERE id=240;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"计算大赛,班级排名\" WHERE id=241;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"A卷（满分100）,班排\" WHERE id=242;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总成绩,班排,A卷分（总80）,B卷分（总20）\" WHERE id=243;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"英语\" WHERE id=244;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"英语\" WHERE id=245;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"A卷,排名\" WHERE id=247;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"英语(100分),A卷分,B卷分\" WHERE id=248;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"英语(100分)\" WHERE id=249;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"U4-5测试 (满分100 A卷80+B卷20),年排(不含英三)\" WHERE id=252;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"U4-5测试 (满分100 A卷80+B卷20),年排(不含英三)\" WHERE id=253;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分\" WHERE id=254;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,班排,年排\" WHERE id=259;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,班排,年排\" WHERE id=260;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩\" WHERE id=262;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,班排,年排\" WHERE id=265;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,班排,年排\" WHERE id=266;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,年排\" WHERE id=269;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,年排\" WHERE id=270;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩\" WHERE id=274;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩\" WHERE id=275;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,班排,年排\" WHERE id=277;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"成绩\" WHERE id=285;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"成绩\" WHERE id=286;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"A卷,B卷\" WHERE id=288;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"成绩\" WHERE id=289;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"英语\" WHERE id=290;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"英语\" WHERE id=291;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"数学,两班排名\" WHERE id=292;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分\" WHERE id=293;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分\" WHERE id=294;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分\" WHERE id=296;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分\" WHERE id=299;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学,英语,化学,物理\", available=\"语文总分,数学总分,英语总分,物理总分,化学总分\" WHERE id=303;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,班排,年排\" WHERE id=305;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,班排,年排\" WHERE id=306;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"历史\", available=\"历史模拟一成绩\" WHERE id=308;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"历史\", available=\"历史模拟一成绩\" WHERE id=309;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"历史\", available=\"历史模拟一成绩\" WHERE id=310;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"历史\", available=\"历史模拟一成绩\" WHERE id=312;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"历史\", available=\"历史模拟一成绩\" WHERE id=313;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"历史\", available=\"历史模拟一成绩\" WHERE id=314;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"历史\", available=\"历史模拟一成绩\" WHERE id=315;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"历史\", available=\"历史模拟二成绩\" WHERE id=318;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"历史\", available=\"历史模拟二成绩\" WHERE id=319;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"历史\", available=\"历史模拟二成绩\" WHERE id=320;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"历史\", available=\"历史模拟二成绩\" WHERE id=321;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学,英语,道法,历史,地理,生物\", available=\"语总,数总,英总,三科总,道法成绩,历史成绩,地理成绩,生物成绩,七科总分\" WHERE id=339;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学,英语,道德与法治,历史,地理,生物,物理\", available=\"语文总,语文排名,数学总,数学排名,英语总,英语排名,物理总,物理排名,五科总分,期末五科排名,道法成绩,历史成绩,生物成绩,地理成绩,十科总分,期末十科排名,期中排名\" WHERE id=341;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学,英语,物理,道德与法治,历史,生物,地理\", available=\"语文总,数学总,英语总,物理总,四科总分,四科排名,道法成绩,道法总分,历史成绩,历史总分,生物成绩,生物总分,地理成绩,地理总分\" WHERE id=344;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学,英语,物理,化学,道法,历史\", available=\"语文总,数学总,英语总,物理总,化学总,五科总分,道法成绩,历史成绩\" WHERE id=345;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,班排,年排\" WHERE id=352;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,班排,年排\" WHERE id=353;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,A卷(满分100),B卷(满分20)\" WHERE id=354;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分,排名\" WHERE id=355;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分,位次\" WHERE id=356;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"总\" WHERE id=363;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"数学\" WHERE id=364;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分,位次\" WHERE id=368;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分,位次\" WHERE id=372;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,班排,年排\" WHERE id=373;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,班排,年排\" WHERE id=374;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,A卷分,B卷分\" WHERE id=375;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,年排(不含三层)\" WHERE id=376;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,年排(不含三层)\" WHERE id=377;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,班排,年排\" WHERE id=380;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,年排\" WHERE id=381;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩\" WHERE id=382;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩（总分100）,A卷总分80,B卷总分20\" WHERE id=383;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩\" WHERE id=385;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩\" WHERE id=386;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"B卷,排名\" WHERE id=387;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"U3 A卷\" WHERE id=401;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,班排,年排\" WHERE id=402;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,班排,年排\" WHERE id=403;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩(满分115),年级PM(共177人),班级PM\" WHERE id=404;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文\", available=\"总分\" WHERE id=409;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分,位次\" WHERE id=410;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分,位次\" WHERE id=411;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分\" WHERE id=412;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总成绩,4个班排\" WHERE id=413;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"A卷总分(满分100),B卷总分(满分50)\" WHERE id=414;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分(150),年排(除3层)\" WHERE id=420;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分(150),年排(除3层)\" WHERE id=421;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总,排名\" WHERE id=422;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分150\" WHERE id=427;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学,英语\", available=\"语总,数总,英总,三科总\" WHERE id=432;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学,英语,物理,生物,地理\", available=\"语文总,数学总,英语总,物理总,五科总分,生物总分,地理总分,十科总分\" WHERE id=436;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学,英语,物理,化学\", available=\"语文总分,数学总分,英语总分,物理总分,化学总分,总分\" WHERE id=439;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"生物\", available=\"模考1总分\" WHERE id=442;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"地理\", available=\"地理\" WHERE id=449;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"A卷,位次\" WHERE id=454;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学,英语,道德与法治,历史,地理,生物,化学,物理\", available=\"七下总分,八下总分,九上总分,九下总分\" WHERE id=455;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"英语总分,英语排名\" WHERE id=457;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"A卷,位次\" WHERE id=461;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"地理\", available=\"地理25年真题\" WHERE id=465;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"地理\", available=\"地理24年真题\" WHERE id=468;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"AB卷(满120分),英三4个班PM(共178个人),A卷(满100分),B卷(满20分),班级PM(共37人)\" WHERE id=469;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,班排,年排\" WHERE id=470;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,班排,年排\" WHERE id=471;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"B卷,位次\" WHERE id=473;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"数学\" WHERE id=477;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"总\" WHERE id=478;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"排名\" WHERE id=479;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"数学（150）,排名\" WHERE id=480;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"U5 A卷（总分100）,U3-4 A卷（总分70）\" WHERE id=486;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"U5A卷（总分100）\" WHERE id=487;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总,排名\" WHERE id=488;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总,排名\" WHERE id=489;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"数学\" WHERE id=493;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分,位次\" WHERE id=494;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"道法,历史\", available=\"道法,历史\" WHERE id=495;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"地理,生物\", available=\"地理成绩,生物学成绩\" WHERE id=498;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"道德与法治,历史\", available=\"道法成绩,历史成绩\" WHERE id=499;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"总分,位次\" WHERE id=500;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文,数学,英语,物理,化学\", available=\"语文总,数学总,英语总,物理总,化学总,五科总分\" WHERE id=504;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"U5总分（满分135）\" WHERE id=505;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,班排,年排\" WHERE id=513;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,班排,年排\" WHERE id=514;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,年排\" WHERE id=518;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"AB卷总分150,A卷100,B卷50,班级PM 38\" WHERE id=519;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"英语总分,年排(含三层)\" WHERE id=520;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"英语总分\" WHERE id=521;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,位次\" WHERE id=526;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩,位次\" WHERE id=527;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文\", available=\"成绩\" WHERE id=548;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文\", available=\"成绩\" WHERE id=549;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文\", available=\"成绩\" WHERE id=550;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文\", available=\"A卷100分,B卷50分\" WHERE id=552;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"语文\", available=\"A卷100分,B卷50分\" WHERE id=553;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"数学\", available=\"数学总分\" WHERE id=555;\n",
    "UPDATE temp_schoolwork_plan SET subject=\"英语\", available=\"成绩\" WHERE id=556;\n",
    "\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "6c22e1e7",
   "metadata": {},
   "outputs": [
    {
     "ename": "ProgrammingError",
     "evalue": "(1064, 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \\'UPDATE temp_schoolwork_plan SET subject=\"道德与法治,历史\", available=\"道\\' at line 2')",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mProgrammingError\u001b[39m                          Traceback (most recent call last)",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[6]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m cursor.execute(sql)\n",
      "\u001b[36mFile \u001b[39m\u001b[32m/app/conda/lib/python3.12/site-packages/pymysql/cursors.py:159\u001b[39m, in \u001b[36mCursor.execute\u001b[39m\u001b[34m(self, query, args)\u001b[39m\n\u001b[32m    155\u001b[39m     \u001b[38;5;28;01mpass\u001b[39;00m\n\u001b[32m    157\u001b[39m query = \u001b[38;5;28mself\u001b[39m.mogrify(query, args)\n\u001b[32m--> \u001b[39m\u001b[32m159\u001b[39m result = \u001b[30;43mself\u001b[39;49m\u001b[30;43m.\u001b[39;49m\u001b[30;43m_query\u001b[39;49m\u001b[30;43m(\u001b[39;49m\u001b[30;43mquery\u001b[39;49m\u001b[30;43m)\u001b[39;49m\n\u001b[32m    160\u001b[39m \u001b[38;5;28mself\u001b[39m._executed = query\n\u001b[32m    161\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m result\n",
      "\u001b[36mFile \u001b[39m\u001b[32m/app/conda/lib/python3.12/site-packages/pymysql/cursors.py:330\u001b[39m, in \u001b[36mCursor._query\u001b[39m\u001b[34m(self, q)\u001b[39m\n\u001b[32m    328\u001b[39m conn = \u001b[38;5;28mself\u001b[39m._get_db()\n\u001b[32m    329\u001b[39m \u001b[38;5;28mself\u001b[39m._clear_result()\n\u001b[32m--> \u001b[39m\u001b[32m330\u001b[39m \u001b[30;43mconn\u001b[39;49m\u001b[30;43m.\u001b[39;49m\u001b[30;43mquery\u001b[39;49m\u001b[30;43m(\u001b[39;49m\u001b[30;43mq\u001b[39;49m\u001b[30;43m)\u001b[39;49m\n\u001b[32m    331\u001b[39m \u001b[38;5;28mself\u001b[39m._do_get_result()\n\u001b[32m    332\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m.rowcount\n",
      "\u001b[36mFile \u001b[39m\u001b[32m/app/conda/lib/python3.12/site-packages/pymysql/connections.py:582\u001b[39m, in \u001b[36mConnection.query\u001b[39m\u001b[34m(self, sql, unbuffered)\u001b[39m\n\u001b[32m    580\u001b[39m     sql = sql.encode(\u001b[38;5;28mself\u001b[39m.encoding, \u001b[33m\"\u001b[39m\u001b[33msurrogateescape\u001b[39m\u001b[33m\"\u001b[39m)\n\u001b[32m    581\u001b[39m \u001b[38;5;28mself\u001b[39m._execute_command(COMMAND.COM_QUERY, sql)\n\u001b[32m--> \u001b[39m\u001b[32m582\u001b[39m \u001b[38;5;28mself\u001b[39m._affected_rows = \u001b[30;43mself\u001b[39;49m\u001b[30;43m.\u001b[39;49m\u001b[30;43m_read_query_result\u001b[39;49m\u001b[30;43m(\u001b[39;49m\u001b[30;43munbuffered\u001b[39;49m\u001b[30;43m=\u001b[39;49m\u001b[30;43munbuffered\u001b[39;49m\u001b[30;43m)\u001b[39;49m\n\u001b[32m    583\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m._affected_rows\n",
      "\u001b[36mFile \u001b[39m\u001b[32m/app/conda/lib/python3.12/site-packages/pymysql/connections.py:847\u001b[39m, in \u001b[36mConnection._read_query_result\u001b[39m\u001b[34m(self, unbuffered)\u001b[39m\n\u001b[32m    845\u001b[39m     result.init_unbuffered_query()\n\u001b[32m    846\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m847\u001b[39m     \u001b[30;43mresult\u001b[39;49m\u001b[30;43m.\u001b[39;49m\u001b[30;43mread\u001b[39;49m\u001b[30;43m(\u001b[39;49m\u001b[30;43m)\u001b[39;49m\n\u001b[32m    848\u001b[39m \u001b[38;5;28mself\u001b[39m._result = result\n\u001b[32m    849\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m result.server_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",
      "\u001b[36mFile \u001b[39m\u001b[32m/app/conda/lib/python3.12/site-packages/pymysql/connections.py:1245\u001b[39m, in \u001b[36mMySQLResult.read\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m   1243\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mread\u001b[39m(\u001b[38;5;28mself\u001b[39m):\n\u001b[32m   1244\u001b[39m     \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m-> \u001b[39m\u001b[32m1245\u001b[39m         first_packet = \u001b[30;43mself\u001b[39;49m\u001b[30;43m.\u001b[39;49m\u001b[30;43mconnection\u001b[39;49m\u001b[30;43m.\u001b[39;49m\u001b[30;43m_read_packet\u001b[39;49m\u001b[30;43m(\u001b[39;49m\u001b[30;43m)\u001b[39;49m\n\u001b[32m   1247\u001b[39m         \u001b[38;5;28;01mif\u001b[39;00m first_packet.is_ok_packet():\n\u001b[32m   1248\u001b[39m             \u001b[38;5;28mself\u001b[39m._read_ok_packet(first_packet)\n",
      "\u001b[36mFile \u001b[39m\u001b[32m/app/conda/lib/python3.12/site-packages/pymysql/connections.py:803\u001b[39m, in \u001b[36mConnection._read_packet\u001b[39m\u001b[34m(self, packet_type)\u001b[39m\n\u001b[32m    801\u001b[39m     \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\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._result.unbuffered_active \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m:\n\u001b[32m    802\u001b[39m         \u001b[38;5;28mself\u001b[39m._result.unbuffered_active = \u001b[38;5;28;01mFalse\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m803\u001b[39m     \u001b[30;43mpacket\u001b[39;49m\u001b[30;43m.\u001b[39;49m\u001b[30;43mraise_for_error\u001b[39;49m\u001b[30;43m(\u001b[39;49m\u001b[30;43m)\u001b[39;49m\n\u001b[32m    804\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m packet\n",
      "\u001b[36mFile \u001b[39m\u001b[32m/app/conda/lib/python3.12/site-packages/pymysql/protocol.py:219\u001b[39m, in \u001b[36mMysqlPacket.raise_for_error\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m    217\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m DEBUG:\n\u001b[32m    218\u001b[39m     \u001b[38;5;28mprint\u001b[39m(\u001b[33m\"\u001b[39m\u001b[33merrno =\u001b[39m\u001b[33m\"\u001b[39m, errno)\n\u001b[32m--> \u001b[39m\u001b[32m219\u001b[39m \u001b[30;43merr\u001b[39;49m\u001b[30;43m.\u001b[39;49m\u001b[30;43mraise_mysql_exception\u001b[39;49m\u001b[30;43m(\u001b[39;49m\u001b[30;43mself\u001b[39;49m\u001b[30;43m.\u001b[39;49m\u001b[30;43m_data\u001b[39;49m\u001b[30;43m)\u001b[39;49m\n",
      "\u001b[36mFile \u001b[39m\u001b[32m/app/conda/lib/python3.12/site-packages/pymysql/err.py:154\u001b[39m, in \u001b[36mraise_mysql_exception\u001b[39m\u001b[34m(data)\u001b[39m\n\u001b[32m    152\u001b[39m \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[32m    153\u001b[39m     errorclass = InternalError \u001b[38;5;28;01mif\u001b[39;00m errno < \u001b[32m1000\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m OperationalError\n\u001b[32m--> \u001b[39m\u001b[32m154\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m errorclass(errno, errval, sqlstate=sqlstate)\n",
      "\u001b[31mProgrammingError\u001b[39m: (1064, 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \\'UPDATE temp_schoolwork_plan SET subject=\"道德与法治,历史\", available=\"道\\' at line 2')"
     ]
    }
   ],
   "source": [
    "cursor.execute(sql)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "189ad30a",
   "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.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
