您的位置:首页 > 博客中心 > 数据库 >

Python脚本传参和Python中调用mysqldump

时间:2022-03-10 17:55

Python脚本传参和Python中调用mysqldump<pre name="code" class="python">#coding=utf-8
import MySQLdb
import sys
import os

# 李红颖编写,用户湖南CLV数据分割使用
print 'dump database:',sys.argv[1] ##传入的第一个参数,数据库名称
print 'dump table:',sys.argv[2]    ##传入的第二个参数,表名称
dbname=sys.argv[1]
tablename=sys.argv[2]


#同步数据值分析服务器2:
# region_id:B C D E
dump101='mysqldump -h10.33.2.71 -uprobe -P5029 -pprobe@2014  --database '+dbname+' --table '+tablename+' -w"region_id in(\'B\',\'C\',\'D\',\'E\')" | mysql  -h192.168.106.101 -uprobe  -pprobe@2014 -P5029  '+dbname
result=os.system(dump101)

#同步数据值分析服务器3:
# region_id:F G H I
dump102='mysqldump -h10.33.2.71 -uprobe -P5029 -pprobe@2014  --database '+dbname+' --table '+tablename+' -w"region_id in(\'F\',\'G\',\'H\',\'I\')" | mysql  -h192.168.106.102 -uprobe  -pprobe@2014 -P5029  '+dbname
result=os.system(dump102)

#同步数据值分析服务器4:
# region_id:J K L M N
dump103='mysqldump -h10.33.2.71 -uprobe -P5029 -pprobe@2014  --database '+dbname+' --table '+tablename+' -w"region_id in(\'J\',\'K\',\'L\',\'M\',\'N\')" | mysql  -h192.168.106.103 -uprobe  -pprobe@2014 -P5029  '+dbname
result=os.system(dump103)

Python脚本传参和Python中调用mysqldump,布布扣,bubuko.com

热门排行

今日推荐

热门手游