本文整理汇总了Python中boto.sdb.connection.SDBConnection.lookup方法的典型用法代码示例。如果您正苦于以下问题:Python SDBConnection.lookup方法的具体用法?Python SDBConnection.lookup怎么用?Python SDBConnection.lookup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boto.sdb.connection.SDBConnection
的用法示例。
在下文中一共展示了SDBConnection.lookup方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_latest_snapshot
# 需要导入模块: from boto.sdb.connection import SDBConnection [as 别名]
# 或者: from boto.sdb.connection.SDBConnection import lookup [as 别名]
def get_latest_snapshot(key, access, name):
sdb = SDBConnection(key, access, region=region_info)
domain = sdb.lookup(name, True)
if domain == None:
domain = sdb.create_domain(name)
return domain.get_item('snapshot', True)['snapshot']
示例2: delete_snapshot
# 需要导入模块: from boto.sdb.connection import SDBConnection [as 别名]
# 或者: from boto.sdb.connection.SDBConnection import lookup [as 别名]
def delete_snapshot(key, access, name, snapshot_id):
sdb = SDBConnection(key, access, region=region_info)
domain = sdb.lookup(name, True)
if domain == None:
domain = sdb.create_domain(name)
return domain.delete_item(domain.get_item(snapshot_id))
示例3: get_all_snapshots
# 需要导入模块: from boto.sdb.connection import SDBConnection [as 别名]
# 或者: from boto.sdb.connection.SDBConnection import lookup [as 别名]
def get_all_snapshots(key, access, name):
sdb = SDBConnection(key, access, region=region_info)
domain = sdb.lookup(name, True)
if domain == None:
domain = sdb.create_domain(name)
now = strftime("%Y-%m-%d %H:%M:%S", gmtime())
select = "select * from `{0}` where itemName() > 'snap-' and itemName() != 'snapshot'".format(name)
snapshots = domain.select(select, consistent_read=True)
return snapshots
示例4: SDB
# 需要导入模块: from boto.sdb.connection import SDBConnection [as 别名]
# 或者: from boto.sdb.connection.SDBConnection import lookup [as 别名]
def SDB(domain_name):
"""
Create connection to SimpleDB and return the specifed domain.
domain_name - the SimpleDB domain you wish to return
"""
conn = SDBConnection(ACCESS_KEY_ID,SECRET_ACCESS_KEY)
domain = conn.lookup(domain_name)
if not domain:
domain = conn.create_domain(domain_name)
return domain
示例5: get_expired_snapshots
# 需要导入模块: from boto.sdb.connection import SDBConnection [as 别名]
# 或者: from boto.sdb.connection.SDBConnection import lookup [as 别名]
def get_expired_snapshots(key, access, cluster):
sdb = SDBConnection(key, access, region=region_info)
domain = sdb.lookup(cluster, True)
if domain == None:
domain = sdb.create_domain(cluster)
now = strftime("%Y-%m-%d %H:%M:%S", gmtime())
select = "select * from `{0}` where itemName() > 'snap-' and itemName() != 'snapshot' and expires < '{1}'".format(
cluster, now
)
snapshots = domain.select(select, consistent_read=True)
return snapshots
示例6: add_snapshot
# 需要导入模块: from boto.sdb.connection import SDBConnection [as 别名]
# 或者: from boto.sdb.connection.SDBConnection import lookup [as 别名]
def add_snapshot(key, access, cluster, name, snapshot):
sdb = SDBConnection(key, access, region=region_info)
domain = sdb.lookup(cluster, True)
if domain == None:
domain = sdb.create_domain(cluster)
now = strftime("%Y-%m-%d %H:%M:%S", gmtime())
# add the snapshot for expiration
backup = domain.new_item(snapshot[0])
backup.add_value("name", name)
backup.add_value("snapshot", snapshot[0])
backup.add_value("created", now)
backup.add_value("expires", snapshot[1])
backup.save()
示例7: get_latest_snapshot
# 需要导入模块: from boto.sdb.connection import SDBConnection [as 别名]
# 或者: from boto.sdb.connection.SDBConnection import lookup [as 别名]
def get_latest_snapshot(key, access, cluster, name):
sdb = SDBConnection(key, access, region=region_info)
now = strftime("%Y-%m-%d %H:%M:%S", gmtime())
domain = sdb.lookup(cluster, True)
if domain == None:
domain = sdb.create_domain(cluster)
select = "select * from `{0}` where name = '{1}' and created < '{2}' order by created desc limit 1".format(
cluster, name, now
)
snapshots = domain.select(select, consistent_read=True)
try:
snapshot = snapshots.next()
return snapshot["snapshot"]
except:
return None
示例8: add_snapshot
# 需要导入模块: from boto.sdb.connection import SDBConnection [as 别名]
# 或者: from boto.sdb.connection.SDBConnection import lookup [as 别名]
def add_snapshot(key, access, name, snapshot):
sdb = SDBConnection(key, access, region=region_info)
domain = sdb.lookup(name, True)
if domain == None:
domain = sdb.create_domain(name)
now = strftime("%Y-%m-%d %H:%M:%S", gmtime())
# add the snapshot for expiration
backup = domain.new_item(snapshot[0])
backup.add_value('snapshot', snapshot[0])
backup.add_value('created', now)
backup.add_value('expires', snapshot[1])
backup.save()
# add the latest (for automatic restores)
latest = domain.new_item('snapshot')
latest.add_value('snapshot', snapshot[0])
latest.save()