Exemple #1
0
def get_or_create_table(dynamodb, name, options):
    """Get or create a table.
    """
    if name in dynamodb.list_tables():
        return dynamodb.get_table(name)

    params = [options['hash'], str]
    if options.get('range'):
        params.extend([options['range'], str])

    table = dynamodb.create_table(
        name,
        dynamodb.create_schema(*params),
        *options['throughput'])

    # Wait till the table is ready to use, about 15s
    while True:
        if table.status != 'ACTIVE':
            time.sleep(4)
            table.refresh()
            continue
        break
    return table
Exemple #2
0
def test_dynamodb_with_connect_to_region():
    # this will work if connected with boto.connect_dynamodb()
    dynamodb = boto.dynamodb.connect_to_region('us-west-2')

    schema = dynamodb.create_schema('column1', str(), 'column2', int())
    dynamodb.create_table('table1', schema, 200, 200)
Exemple #3
0
def test_dynamodb_with_connect_to_region():
    # this will work if connected with boto.connect_dynamodb()
    dynamodb = boto.dynamodb.connect_to_region("us-west-2")

    schema = dynamodb.create_schema("column1", str(), "column2", int())
    dynamodb.create_table("table1", schema, 200, 200)
Exemple #4
0
def test_dynamodb_with_connect_to_region():
    # this will work if connected with boto.connect_dynamodb()
    dynamodb = boto.dynamodb.connect_to_region("us-west-2")

    schema = dynamodb.create_schema("column1", str(), "column2", int())
    dynamodb.create_table("table1", schema, 200, 200)