def c_table (Table, t_config): # create dynamo DB tables
"""
try to create table, if it errors tables exist,
drop the tables, and then rerun the function to create again.
"""
try:
print "INFO :: Creating %s Table....." % Table
db_r.create_table(
AttributeDefinitions = t_config[Table]['AttributeDefinitions'],
TableName=Table,
KeySchema = t_config[Table]['KeySchema'],
ProvisionedThroughput=t_config[Table]['ProvisionedThroughput']
)
print "INFO :: Waiting for completion..."
db_r.Table(Table).wait_until_exists()
except botocore.exceptions.ClientError as e:
if e.response['Error']['Code'] == "ResourceInUseException":
print "INFO :: Learning Online %s Table exists, deleting ...." % Table
db_r.Table(Table).delete()
print "INFO :: Waiting for delete.."
db_r.Table(Table).wait_until_not_exists()
c_table (Table, t_config)
else:
print "Unknown Error"
#------------------------------------------------------------------------------
评论列表
文章目录