def get_env_iter(): db = Connection('/tmp/mysql3306.sock', config.DB_NAME, config.DB_USER, config.DB_PASSWD, time_zone='+8:00') v_show_env_type = config.SHOW_ENV_TYPE if v_show_env_type==1: v_more_sql = '' elif v_show_env_type==2: #id =3 表示生产环境 v_more_sql = ' and id=3' elif v_show_env_type==3: v_more_sql = ' and id!=3' else: pass str_sql = "select id,name from resources_env where 1=1 %s order by id" % (v_more_sql) env_list = db.iter(str_sql) db.close() return env_list
def upload_processlist(): # 连接配置中心库 # db = Connection('/home/apps/inception/inc.socket', # '', # '', # '', # time_zone='+8:00') db = Connection("127.0.0.1:6669", "", "", "", time_zone="+8:00") print "aa" v_sql = r"""/*--user=mysqladmin;--password=mysql;--host=172.26.137.125; --enable-check;--port=3306;*/ inception_magic_start; use test; CREATE TABLE adaptive_office23(id int); inception_magic_commit;""" # print v_sql upload_server_list = db.iter(v_sql) if upload_server_list: # 对实例表进行循环 i = 0 print upload_server_list for upload_server in upload_server_list: stage = upload_server["stage"] print stage stagestatus = upload_server["stagestatus"] print stagestatus # mysql_port = upload_server['port'] # v_host =host_ip + ':' + str(mysql_port) # i=i+1 db.close()