修改mysql数据
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | import time import pymysql import schedule def job(): # 连接数据库 connect = pymysql.Connect( host = '140.210.4.73' , port = 3306 , user = 'twipad_cj' , passwd = 'bj@#twipad_cj' , db = 'tw_ipaddb' , charset = 'utf8mb4' ) cursor = connect.cursor() try : sql1 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛蓝" where ir_keyword="国民党"' sql2 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿" where ir_keyword="绿党"' sql3 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿" where ir_keyword="民进党"' sql4 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿" where ir_keyword="社会民主党"' sql5 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿" where ir_keyword="时代力量"' sql6 = 'update hkby_facebookhistory_abroaddataall set ir_camp="红统派" where ir_keyword="亲民党"' sql7 = 'update hkby_facebookhistory_abroaddataall set ir_camp="红统派" where ir_keyword="统促党"' sql8 = 'update hkby_facebookhistory_abroaddataall set ir_camp="红统派" where ir_keyword="新党"' sql9 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛蓝" where ir_keyword="致公党"' sql10 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛蓝",ir_from="其他" where ir_keyword="郝龙斌"' sql11 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛蓝",ir_from="台北市" where ir_keyword="蔡正元"' sql12 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛蓝",ir_from="台中市" where ir_keyword="江启臣"' sql13 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿",ir_from="高雄市" where ir_keyword="3Q 陈柏惟"' sql14 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛蓝",ir_from="花莲县" where ir_keyword="徐榛蔚"' sql15 = 'update hkby_facebookhistory_abroaddataall set ir_camp="其他",ir_from="台北市" where ir_keyword="柯文哲"' sql16 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛蓝",ir_from="其他" where ir_keyword="朱立伦"' sql17 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛蓝",ir_from="新北市" where ir_keyword="侯友宜"' sql18 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿",ir_from="台北市" where ir_keyword="姚文智"' sql19 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿",ir_from="其他" where ir_keyword="段宜康"' sql20 = 'update hkby_facebookhistory_abroaddataall set ir_camp="其他",ir_from="其他" where ir_keyword="陈建仁 Chen Chien-Jen"' sql21 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿",ir_from="高雄市" where ir_keyword="赵天麟"' sql22 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿",ir_from="台中市" where ir_keyword="蔡其昌"' sql23 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿",ir_from="花莲县" where ir_keyword="萧美琴"' sql24 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿",ir_from="其他" where ir_keyword="郭正亮"' sql25 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿",ir_from="新北市" where ir_keyword="黄国昌"' sql26 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿",ir_from="台北市" where ir_keyword="林昶佐 Freddy Lim"' sql27 = 'update hkby_facebookhistory_abroaddataall set ir_camp="红统派",ir_from="其他" where ir_keyword="王炳忠"' sql28 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿",ir_from="其他" where ir_keyword="蔡英文 Tsai Ing-wen"' sql29 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛蓝",ir_from="高雄市" where ir_keyword="韩国瑜"' sql30 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿",ir_from="其他" where ir_keyword="陈水扁(Chen Shui-bian)"' sql31 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛蓝",ir_from="其他" where ir_keyword="马英九"' sql32 = 'update hkby_facebookhistory_abroaddataall set ir_camp="其他",ir_from="彰化县" where ir_keyword="林全"' sql33 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛蓝",ir_from="其他" where ir_keyword="萧万长"' sql34 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛蓝",ir_from="其他" where ir_keyword="洪秀柱"' sql35 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛蓝",ir_from="台北市" where ir_keyword="罗智强"' sql36 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿",ir_from="新北市" where ir_keyword="苏贞昌"' sql37 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿",ir_from="其他" where ir_keyword="谢长廷"' sql38 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿",ir_from="其他" where ir_keyword="游锡堃"' sql39 = 'update hkby_facebookhistory_abroaddataall set ir_camp="红统派",ir_from="其他" where ir_keyword="邱毅"' sql40 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿",ir_from="台中市" where ir_keyword="林佳龙"' sql41 = 'update hkby_facebookhistory_abroaddataall set ir_camp="其他",ir_from="金门县" where ir_keyword="陈福海"' sql42 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛蓝",ir_from="屏东县" where ir_keyword="曾永权"' sql43 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛蓝",ir_from="其他" where ir_keyword="王育敏"' sql44 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿",ir_from="新竹市" where ir_keyword="林智坚"' sql45 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿",ir_from="桃园市" where ir_keyword="郑文灿"' sql46 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿",ir_from="高雄市" where ir_keyword="陈其迈"' sql47 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿" where ir_keyword="公投护台湾联盟"' sql48 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿" where ir_keyword="基进党"' sql49 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿" where ir_keyword="台联党"' sql50 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿" where ir_keyword="新境界文教基金会"' sql51 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛绿" where ir_keyword="自由台湾党"' sql52 = 'update hkby_facebookhistory_abroaddataall set ir_camp="泛蓝",ir_from="台北市" where ir_keyword="费鸿泰(阿力克司)"' cursor.execute(sql1) cursor.execute(sql2) cursor.execute(sql3) cursor.execute(sql4) cursor.execute(sql5) cursor.execute(sql6) cursor.execute(sql7) cursor.execute(sql8) cursor.execute(sql9) cursor.execute(sql10) cursor.execute(sql11) cursor.execute(sql12) cursor.execute(sql13) cursor.execute(sql14) cursor.execute(sql15) cursor.execute(sql16) cursor.execute(sql17) cursor.execute(sql18) cursor.execute(sql19) cursor.execute(sql20) cursor.execute(sql21) cursor.execute(sql22) cursor.execute(sql23) cursor.execute(sql24) cursor.execute(sql25) cursor.execute(sql26) cursor.execute(sql27) cursor.execute(sql28) cursor.execute(sql29) cursor.execute(sql30) cursor.execute(sql31) cursor.execute(sql32) cursor.execute(sql33) cursor.execute(sql34) cursor.execute(sql35) cursor.execute(sql36) cursor.execute(sql37) cursor.execute(sql38) cursor.execute(sql39) cursor.execute(sql40) cursor.execute(sql41) cursor.execute(sql42) cursor.execute(sql43) cursor.execute(sql44) cursor.execute(sql45) cursor.execute(sql46) cursor.execute(sql47) cursor.execute(sql48) cursor.execute(sql49) cursor.execute(sql50) cursor.execute(sql51) cursor.execute(sql52) connect.commit() print ( '修改成功' ) except : print ( '暂无数据' ) connect.close() job() # if __name__ == '__main__': # while 1: # # 每两秒执行一次 # schedule.every().day.at("11:00").do(job) # schedule.run_pending() |
本文作者:布都御魂
本文链接:https://www.cnblogs.com/wolvies/p/15262978.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步