本文整理匯總了Python中torndb.Connection.iter方法的典型用法代碼示例。如果您正苦於以下問題:Python Connection.iter方法的具體用法?Python Connection.iter怎麽用?Python Connection.iter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類torndb.Connection
的用法示例。
在下文中一共展示了Connection.iter方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_env_iter
# 需要導入模塊: from torndb import Connection [as 別名]
# 或者: from torndb.Connection import iter [as 別名]
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
示例2: upload_processlist
# 需要導入模塊: from torndb import Connection [as 別名]
# 或者: from torndb.Connection import iter [as 別名]
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()