In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Scene: due to the development of disgusting account login settings, and in view of the habits of Japanese players, they have just begun to log in to the game as tourists. If there is a change of package or equipment, the account ID needs to be replaced from the database. At first, it is manual, and then py is implemented, encapsulated as exe, which is directly executed in dos. The best way to improve is, of course, to meet with web with one click, and now the code runs away as a record.
# coding=utf-8import pymysqlimport tracebackimport simplejsonimport sys# Exchange def exchange (connect_index, file_name): try: # read database configuration fp = open ("config.json") connect_info = simplejson.load (fp) ["db_list"] fp.close () # create link conn = pymysql.connect (connect_ in [connect _ index] ["ip"]) Port=int (connect_ InfoConnect [index] ["port"]), user=str (connect_ InfoConnect [connect _ index] ["user"]), passwd=str (connect_ InfoConnect [connect _ index] ["passwd"]), db=str (connect_ InfoConnect [connect _ index] ["db_name"]) Charset='utf8') # get cursor cur = conn.cursor () # read swap list fp = open (str (file_name)) exchange_data = simplejson.load (fp) fp.close () # start exchanging for item in exchange_data: # Read account_id player_datas = [] for i in range (2): temp_data = {} cur.execute ("select `id`) for two values `account_ id` from `room`where `"+ str (item [" key "] [I]) +"` ='"+ str (item [" value "] [I]) +"'") result = cur.fetchall () temp_data [" id "] = result [0] [0] temp_data ["account_id"] = result [0] [1] player_datas.append (temp_data) # change account_id to avoid conflicts for player_data in player_datas: cur.execute ("update `room`set `account_ id` ='" + str (player) _ data ["account_id"]) + "_ 'where `id` ='" + str (player_data ["id"]) + "'") conn.commit () # Exchange temp_data = player_datas [0] ["account_id"] player_datas [0] ["account_id"] = player_datas [1] ["account_id"] player _ datas [1] ["account_id"] = temp_data for player_data in player_datas: cur.execute ("update `room`set `account_ id` ='" + str (player_data ["account_id"]) + "'where `id` ='" + str (player_data ["id"]) + "') conn.commit () conn.close () ) except Exception: traceback.print_exc () if _ _ name__ ='_ _ main__': try: if len (sys.argv) < 3: print "arg error" sys.exit (1) exchange (int (sys.argv [1])) Sys.argv [2]) except Exception: traceback.print_exc ()
Some of the json files haven't been sorted out yet. If you have any questions, ask the blogger, and he won't tell you anyway.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.