In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-10-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Problem description:
This afternoon to run a project db requirements, Baiku Baibai clean up dirty data, and then write a python script, after the run to inform the project, and then the project to the player a reward, the result is sad, all the mysql operations did not succeed (did not report an error, so I thought the implementation was successful).
Here is my python script, passing two files as parameters, host.txt and update.sql
Click (here) to collapse or open
#! / usr/bin/env python
#-*-coding: UTF-8-*-
Import sys
Import MySQLdb
Import datetime
Dbuser = 'xxx'
Dbpwd = 'xxx'
DB_NUM = 100
TB_NUM = 100
Args = sys.argv
If len (args)! = 3:
Print "USAGE:% s host.txt update.sql"% args [0]
Sys.exit ()
Start = datetime.datetime.now ()
Print "Start Time:% s"% start.strftime ('% Y-%m-%d% HRV% MRV% S')
Hostfile = args [1]
Sqlfile = args [2]
Rhost = open (hostfile)
Hostlist = rhost.readlines ()
Rhost.close ()
Rsqls = open (sqlfile)
Sqllist = rsqls.readlines ()
Rsqls.close ()
For host in hostlist:
Host = host.strip ()
Ip = host.split ('') [0]
Pt = host.split ('') [1]
Conn = MySQLdb.connect (ip,dbuser,dbpwd,port=int (pt))
Cursor = conn.cursor ()
Cursor.execute ('SET NAMES UTF8')
Sqls = []
For i in range (DB_NUM):
Sqls.append ("s" str (I) .zfill (2))
For sql in sqls:
Db=sql
# print 'ip=%s; port=%s; db=%s'% (ip,pt,db)
For j in range (TB_NUM):
If TB_NUM > 10:
J = str (j) .zfill (2)
For sql in sqllist:
Ct = sql.strip ()% (db,str (j)) cursor.execute (ct)
Print ct
Conn.close ()
End= datetime.datetime.now ()
Print "End Time:% s"% end.strftime ('% Y-%m-%d% HRV% MRV% S')
Update.sql is as follows:
Click (here) to collapse or open
Delete from XSY_%s.t_xsy_equip_cloth_%s where (clothid > = 201675 and clothid = 201725 and clothid
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.