diff --git a/README.rst b/README.rst index 8fee536..85de0d5 100644 --- a/README.rst +++ b/README.rst @@ -17,6 +17,9 @@ Usage table = dynamo.table(TABLE_NAME, (ACCESS_KEY, SECRET_ACCESS_KEY)) + # Or, if you have AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY defined as + # environment variables, you can do: + table = dynamo.table(TABLE_NAME) Writing is simple:: diff --git a/dynamo.py b/dynamo.py index 084f802..a842f4d 100644 --- a/dynamo.py +++ b/dynamo.py @@ -110,14 +110,18 @@ class Item(object): return key in self.item -def table(name, auth, eager=True): +def table(name, auth=None, eager=True): """Returns a given table for the given user.""" + auth = auth or [] dynamodb = boto.connect_dynamodb(*auth) + table = dynamodb.get_table(name) return Table(table=table, eager=eager) -def tables(auth, eager=True): +def tables(auth=None, eager=True): """Returns a list of tables for the given user.""" + auth = auth or [] dynamodb = boto.connect_dynamodb(*auth) + return [table(t, auth, eager=eager) for t in dynamodb.list_tables()]