parent
7d02d3367a
commit
cf8752e444
@ -1,8 +0,0 @@
|
|||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
# Datasource local storage ignored files
|
|
||||||
/dataSources/
|
|
||||||
/dataSources.local.xml
|
|
||||||
# Editor-based HTTP Client requests
|
|
||||||
/httpRequests/
|
|
@ -1,12 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
|
||||||
<data-source source="LOCAL" name="progress" uuid="d4f76e3d-c68e-4c11-bc55-8d75bbb7c305">
|
|
||||||
<driver-ref>sqlite.xerial</driver-ref>
|
|
||||||
<synchronize>true</synchronize>
|
|
||||||
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
|
|
||||||
<jdbc-url>jdbc:sqlite:D:\python\ETL\db\progress.db</jdbc-url>
|
|
||||||
<working-dir>$ProjectFileDir$</working-dir>
|
|
||||||
</data-source>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="Encoding">
|
|
||||||
<file url="file://$PROJECT_DIR$/Data/t_pro_attach.json" charset="GBK" />
|
|
||||||
<file url="file://$PROJECT_DIR$/PaChong/WuBin/说明.txt" charset="UTF-8" />
|
|
||||||
<file url="file://$PROJECT_DIR$/txt_save.txt" charset="GBK" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -1,6 +0,0 @@
|
|||||||
<component name="InspectionProjectProfileManager">
|
|
||||||
<settings>
|
|
||||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
|
||||||
<version value="1.0" />
|
|
||||||
</settings>
|
|
||||||
</component>
|
|
@ -1,4 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6 (AutoCodeGenerate)" project-jdk-type="Python SDK" />
|
|
||||||
</project>
|
|
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectModuleManager">
|
|
||||||
<modules>
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/pythonProject.iml" filepath="$PROJECT_DIR$/.idea/pythonProject.iml" />
|
|
||||||
</modules>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="PYTHON_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager">
|
|
||||||
<content url="file://$MODULE_DIR$" />
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="SqlDialectMappings">
|
|
||||||
<file url="file://$PROJECT_DIR$/Doc/项目单位代码的补全.sql" dialect="MariaDB" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -0,0 +1,5 @@
|
|||||||
|
user=root
|
||||||
|
password=DsideaL147258369
|
||||||
|
host=10.10.14.230
|
||||||
|
port=22066
|
||||||
|
database=test
|
@ -0,0 +1,102 @@
|
|||||||
|
# python -m pip install --upgrade pip -i http://pypi.douban.com/simple/
|
||||||
|
# pip install pymysql -i http://pypi.douban.com/simple/
|
||||||
|
import datetime
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import pymysql.cursors
|
||||||
|
|
||||||
|
|
||||||
|
class MySQLHelper:
|
||||||
|
myVersion = 0.1
|
||||||
|
|
||||||
|
def __init__(self, host, port, db, user, password, charset="utf8"):
|
||||||
|
self.host = host
|
||||||
|
self.user = user
|
||||||
|
self.port = port
|
||||||
|
self.password = password
|
||||||
|
self.charset = charset
|
||||||
|
self.db = db
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.conn = pymysql.connect(host=self.host, port=self.port, user=self.user, passwd=self.password,
|
||||||
|
db=self.db, charset=self.charset, cursorclass=pymysql.cursors.DictCursor)
|
||||||
|
self.cursor = self.conn.cursor()
|
||||||
|
|
||||||
|
# 设置执行时间为8小时
|
||||||
|
sql = "set session wait_timeout=288000"
|
||||||
|
self.cursor.execute(sql)
|
||||||
|
sql = "set session interactive_timeout=288000"
|
||||||
|
self.cursor.execute(sql)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print('MySql Error : %d %s' % (e.args[0], e.args[1]))
|
||||||
|
|
||||||
|
def query(self, sql: object) -> object:
|
||||||
|
try:
|
||||||
|
self.cursor.execute(sql)
|
||||||
|
result = self.cursor.fetchall()
|
||||||
|
return result
|
||||||
|
except Exception as e:
|
||||||
|
print('MySql Error: %s SQL: %s' % (e, sql))
|
||||||
|
|
||||||
|
def execute(self, sql):
|
||||||
|
try:
|
||||||
|
self.cursor.execute(sql)
|
||||||
|
self.conn.commit()
|
||||||
|
# 获取更新了多少条数据
|
||||||
|
return self.cursor.rowcount
|
||||||
|
except Exception as e:
|
||||||
|
print('MySql Error: %s SQL: %s' % (e, sql))
|
||||||
|
|
||||||
|
def executeWithPara(self, sql, params):
|
||||||
|
try:
|
||||||
|
self.cursor.execute(sql, params)
|
||||||
|
self.conn.commit()
|
||||||
|
except Exception as e:
|
||||||
|
print('MySql Error: %s SQL: %s' % (e, sql))
|
||||||
|
|
||||||
|
def executemany(self, sql, data):
|
||||||
|
try:
|
||||||
|
self.cursor.executemany(sql, data)
|
||||||
|
self.conn.commit()
|
||||||
|
except Exception as e:
|
||||||
|
print('MySql Error: %s SQL: %s' % (e, sql))
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
self.cursor.close()
|
||||||
|
self.conn.close()
|
||||||
|
|
||||||
|
|
||||||
|
# 黄海定义的输出信息的办法,带当前时间
|
||||||
|
def logInfo(msg):
|
||||||
|
i = datetime.datetime.now()
|
||||||
|
print(" %s %s" % (i, msg))
|
||||||
|
|
||||||
|
|
||||||
|
# 准备扩展
|
||||||
|
_dict = {
|
||||||
|
"t_resource_base": "update t_resource_base t1,t_dm_stage t2 set t1.CHECK_MESSAGE=t2.stage_name where t1.stage_id=t2.stage_id and t1.CHECK_MESSAGE is null limit 100"}
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
if len(sys.argv) == 1:
|
||||||
|
print("没有正确输入参数,请检查!输入样例: python pack.py t_resource_base")
|
||||||
|
sys.exit()
|
||||||
|
tableName = sys.argv[1]
|
||||||
|
|
||||||
|
# 配置
|
||||||
|
user = 'root'
|
||||||
|
password = 'DsideaL147258369'
|
||||||
|
host = '10.10.14.230'
|
||||||
|
port = 22066
|
||||||
|
database = 'test'
|
||||||
|
|
||||||
|
db = MySQLHelper(user=user, host=host, port=port, password=password, db=database)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
sql = _dict[tableName]
|
||||||
|
cnt = db.execute(sql)
|
||||||
|
logInfo("成功更新%s条" % cnt)
|
||||||
|
if cnt == 0:
|
||||||
|
break
|
||||||
|
|
||||||
|
db.close()
|
Loading…
Reference in new issue