-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.1.0 - naming improvements and added utilties
- Loading branch information
Peter Gaultney
committed
May 28, 2020
1 parent
e07a044
commit b0f32d0
Showing
7 changed files
with
87 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env python | ||
"""This little example script only supports BatchGet on tables with | ||
simple (non-composite) keys (i.e., the base index is HASH only, not | ||
HASH+RANGE) for the sake of keeping the CLI manageable. | ||
However, BatchGetItem itself supports HASH+RANGE keys just fine, where | ||
a key would look something like `dict(activity_group='XOi', | ||
id='job-1234')`. | ||
""" | ||
import argparse | ||
from pprint import pprint | ||
|
||
import boto3 | ||
|
||
from xoto3.dynamodb.batch_get import BatchGetItem, items_only | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description=__doc__) | ||
parser.add_argument("table_name") | ||
parser.add_argument("ids", nargs="+") | ||
parser.add_argument("--key-name", default="id", help="the name of your hash key attribute") | ||
args = parser.parse_args() | ||
|
||
table = boto3.resource("dynamodb").Table(args.table_name) | ||
|
||
for item in items_only( # we don't care about keys, nor items that aren't found | ||
BatchGetItem( | ||
table, | ||
# make a proper ItemKey (a dict) for each of the things you're looking to get | ||
({args.key_name: id} for id in args.ids), | ||
# this is a memory-efficient generator but you can pass a list or tuple of dicts too | ||
) | ||
): | ||
pprint(item) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
"""xoto3""" | ||
__version__ = "1.0.3" | ||
__version__ = "1.1.0" | ||
__author__ = "Peter Gaultney" | ||
__author_email__ = "[email protected]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from .builders import build_update # noqa | ||
from .diff import build_update_diff # noqa | ||
from .diff import build_update_diff, select_attributes_for_set_and_remove # noqa | ||
from .core import UpdateItem, DiffedUpdateItem # noqa | ||
from .versioned import versioned_diffed_update_item, VersionedUpdateFailure # noqa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters