The Rock N' Roll & Coffee Show Podcast

boto3 dynamodb check if item exists

You put numbers in quotes too. For this case you will set up a dynamodb resource for boto3. getting exception while calling Dynamo db updateitem ... SharePoint : Check if item exists in a list, minimum overhead Checking if an item . item (boto.dynamodb.item.Item) - The Item to delete from Amazon DynamoDB. You may also want to check out all available functions/classes of the module boto3.dynamodb.conditions , or try the search function . Is there a way to check if an item exists in a DynamoDB ... I will teach you in this lesson how to create dynamodb table in aws boto3 python, how to insert items in aws boto3, how to retrieve items, how to scan items. Stitcher. Boto3 dynamodb get all items - Professional .NET SDK to ... AWS dynamodb: How to check if item exist in table? : aws First, we're doing a Put operation to insert a new Reaction entity. Amazon DynamoDB is a non-relational key/value store database that provides incredible single-digit millisecond response times for reading or writing, and is unbounded by scaling issues. About S3 If File Resource Exists Boto3 Check . Description Our product sets a nested attribute to a combination of the two functions above to create or append to a history log in DynamoDB. The most efficient method is to fetch the exact key of the item that you're looking for. Condition Expressions - Amazon DynamoDB DynamoDB - Conditional put where hash key not exist ... item (boto.dynamodb.item.Item) - The Item to delete from Amazon DynamoDB. The user can supply a condition to be evaluated by DynamoDB before the operation is performed. Boto3 and moto packages installed; Example: Movies Project. Loads a collection from a model, creating a . Check if DynamoDB table already exists and create one if it doesn't - createTable.py . share. If I install boto3 1.4.0, then the second print() statement "Download complete" is never reached. It returns its status if it exists (CREATE, UPDATE, DELETE, ACTIVE) or a botocore.exceptions.ClientError: Requested resource not found: Table: <YOUR_TABLE_NAME> not found exception exception botocore.exceptions.ClientError: Requested resource not found: Table: <YOUR_TABLE_NAME> not found. If an item that has the same primary key as the new item already exists in the specified table, the new item completely replaces the existing item. Comments. The sort key is optional. StartingToken (string) --A token to specify where to start paginating. # You can use the low-level client to make API calls to DynamoDB.Convert Float to Decimal Data Types for Boto3 DynamoDB Using Python Feb 5 th, 2019 9:45 am A quick post on a workaround when you need to convert float to decimal types.Import boto3 # Get the service resource. Using Boto3, you can operate on DynamoDB stores in pretty much any way you would ever need to. 2. Automating Disaster Recovery on AWS for Financial Services. Use the File. The hash and the range key together serve as a composite primary key, so you're selecting one row, and trying to create a condition that depends on other rows. Delete all items in the specified DynamoDB table. to apply another AttributeBase method like eq (). Store a record of the input text and the resulting mp3 file location in DynamoDB. Original Poster. We treat the cause of your spine/joint problems. {}'.format . If Exists is True, DynamoDB will check to see if that attribute value already exists in the table. You may check out the related API usage on the sidebar. getting errored out with boto3.dynamodb.transform.TransformationInjector object at 0x7fd4ad69cd90. Tutorial on how to upload and download files from Amazon S3 using the Python Boto3 module. To counteract this, we used a condition expression to only insert the Item if an Item with that primary key did not exist previously. I was wondering if there is a way to check if an item exist in my dynamodb table? Steps to reproduce If you have a runnable example, please include it as a snippet or link to a repository/gist for larger code examples. If Exists is True, DynamoDB will check to see if that attribute value already exists in the table. dynamodb = boto3.resource('dynamodb') table = dynamodb.Table('testing_table') Patreon. Example 1. I've play with redis and it have exist method. Notice, however, that you need to enable DEBUG mode in your logger to see any retry attempts. About S3 If File Resource Exists Boto3 Check . The EXISTS function can only be used in transactions. Check if object exists on S3. This dictionary should have name/value pairs where the name is the name of the attribute and the value is either the value you are expecting or False if you expect the attribute not to exist. I'm writing a python script which imports boto to fetch my aws service data. boto3 dynamodb key and sort key example get item. 6 votes. If you need to insert, update or delete multiple items in a single API call, use BatchWrite operation. Expected: the list is created at the specified key if it does not exist with the new item in it. DynamoDB allows us to store complex data structures and deeply nested objects, but this complexity isn't free. You will then specify the table you want to delete items from. 1. level 2. Now its time to set your resource and your table. with the value in the JSON. Also note that I tried following the new doc example with boto3.resource and using s3.meta.client, but that fails as well. 1 Answer1. expected_value - A dictionary of name/value pairs that you expect. To add conditions to scanning and querying the table, you will need to import the boto3.dynamodb.conditions.Key and boto3.dynamodb.conditions.Attr classes. I've try with scan but i need to check my hash_key, not attributes. Archived. For example, if a code raises FileNotFoundException we catch . # in which can be used to generate its attribute base. Suppose that you have defined a Thread Model for the examples below. put_csv (path, table_name[, boto3_session]) Write all items from a CSV file to a DynamoDB. terrycain added the bug label on Nov 22, 2017. terrycain self-assigned this on Nov 22, 2017. terrycain mentioned this issue on Nov 26, 2017. Posted by 5 years ago. Before she can do all that, she needs to create her first boto3 client and check out what buckets already exist in S3. Any advice? def __init__ ( self, *values ): ConditionBase. Previously, we used the PutItem operation to insert Items into our DynamoDB table. def lambda_handler(event, context): # Check DynamoDB Table for existing location. def check_if_item_exist (item): db = awsbackend.development_client ('dynamodb', region='us-west-2') response = db.get_item ( TableName='db-test1', Key= { 'name': {'S': 'item. Is there a way to check if an item exists in a DynamoDB Table without using Query or Scan and that won't cause an exception. def not_exists (self): """Creates a condition where the attribute does not exist.""" return AttributeNotExists (self) . The attribute type is number . Querying and scanning¶. Sign up for free to join this conversation on GitHub . You put numbers in quotes too. dynamodb query by attribute python. Project: aws-media-services-vod-automation Author: aws-samples File: app.py License: Apache License 2.0. You can't. All items in DynamoDB are indexed by either their hash or hash + range (depending on your table). You can use the query method to retrieve data from a table. dynamodb query get all items python. NOTE: Complete Project code in Github -> Pytest for AWS Lambdas and Dynamodb In this article, I'll show you the techniques which I have incorporated into my test suites using Pytest. Active Oldest Votes. python dynamodb get existing table. Please note, that as previously stated, as the Item property, we could have provided a marshalled value.. Batch Write / Put Item. Instagram. 8 months ago. You can read multiple items from the table in a single operation (Query), provided that the items you want have the same partition key value. If the item exists, an exception is raised and lock is not acquired : probably another process is using the resource. But i miss an argument (???). If the total number of items available is more than the value specified in max-items then a NextToken will be provided in the output that you can use to resume pagination. load_from_definition(resource_name, collection_model, service_context, event_emitter) [source] ¶. If it exists, the item will be returned. You will then specify the table you want to delete items from. Conditional Operations. Now, we have an idea of what Boto3 is and what features it provides. Could not do the following check for if the key exists? Comments. This dictionary should have name/value pairs where the name is the name of the attribute and the value is either the value you are expecting or False if you expect the attribute not to exist. This cheat sheet will mostly focus on DocumentClient but some of the operations like creating tables must be run using classical DynamoDB service. download (path, local_file[, version_id, . DynamoDB - Put item if hash (or hash and range combination) doesn't exist. We catch exceptions which have been raised or their parent. If it is found, then the condition evaluates to true; otherwise the condition evaluate to false. We saw that this operation completely overwrites any existing Item in the table. spulec closed this in #1364 on Mar 6, 2018. We had a table of data consisting of ~68000 entries, with a primary hash key with ~35000 items. Close. I've had the chance to use Lambda functions in my recent work, With a low cost of getting started, Lambda has been useful for building small programs which can do a quick set of tasks. With the table full of items, you can then query or scan the items in the table using the DynamoDB.Table.query() or DynamoDB.Table.scan() methods respectively. This method returns True if the specified path is an existing regular file, otherwise returns False. Mirror_rorriM_Mirror. This is especially true for large financial institutions running hundreds if . If Exists is False, DynamoDB assumes that the attribute value does not exist in the table. You can use the .table_status attr of any boto3 Table instance object. DynamoDBを使っていてアイテムが既に存在する場合は、putItemしたくない場合があるかと思います。 そんなときはExpectedで「プライマリーキーの属性が無いこと」を条件にすれば、エラーになり書き込まれません。 以下にサンプルコードを載せておきます。 Jaseng treatment helps bone and nerves to regenerate, by boosting the self-healing power of the body. To complete a condition, you need. Boto3 comes with several other service-specific features, such as automatic multi-part transfers for Amazon S3 and simplified query conditions for DynamoDB. If you're looking for similar cheat sheet but for . Using the EXISTS Function with PartiQL for DynamoDB. It bundles multiple database requests against multiple tables into a single SDK call. This is the NextToken from a previous response. Source code for boto3.dynamodb.conditions . 6 votes. Step 3.1: Create a New Item Step 3.2: Read an Item Step 3.3: Update an Item Step 3.4: Increment an Atomic Counter Step 3.5: Update an Item (Conditionally) Step 3.6: Delete an Item. For this case you will set up a dynamodb resource for boto3. As part of that operation, we're specifying a condition that the SK attribute should not exist for this item.This is a way to ensure that an item with this PK and SK . dynamodb get all items python. If the same alert exists, do nothing. Adds if_not_exists function to DynamoDB Update Expression #1364. This allows the write to proceed only if the item in question does not already have the same key. If you use boto3.client(), you can use the 3 methods the accepted answer suggested.If you are using boto3.resource(), you can only use dynamodb_resource.create_table() and check exceptions.. try: table = dynamodb_resource.create_table( . Store a record of the input text and the resulting mp3 file location in DynamoDB. The total number of items to return. from boto3.dynamodb . This method returns True if the specified path is an existing regular file, otherwise returns False. You can create new tables, read and write data either individually or in bulk, you can delete tables, change table capacities, set up auto-scaling, etc. batch upload json to dynamodb using boto3 Saving data from DynamoDB locally on Android Single SQL query to check if either table contains a row with column=x AWS - want to upload multiple files to S3 and only when all are uploaded trigger a lambda function . terrycain added the bug label on Nov 22, 2017. terrycain self-assigned this on Nov 22, 2017. terrycain mentioned this issue on Nov 26, 2017. You can use EXISTS to perform the same function as ConditionCheck does in the TransactWriteItems API. The following are 30 code examples for showing how to use boto3.resource().These examples are extracted from open source projects. zone = checkLocationTable(os.environ['Address']) # Check NWS Alerts for new alerts. dynamodb scan boto3. For example, we know that the 'artist' is a String because the dictionary object is: {'S': 'Arturus Ardvarkian'}.The S indicates that the value inside is a string type. These subclasses include methods to perform batch operations. If it worked, the lock is acquired and the item is created, preventing another process to take it. Unfortunately, there's no easy way to delete all items from DynamoDB just like in SQL-based databases by using DELETE FROM my-table;.To achieve the same result in DynamoDB, you need to query/scan to get all the items in a table using pagination until all items are scanned and then perform delete operation one-by-one on each record. Dynamodb check if item exists python . Jaseng treatment helps bone and nerves to regenerate, by boosting the self-healing power of the body. The primary key for the Movies table is composed of the following: year - The partition key. boto3 dynamodb get item by primary key. client ('dynamodb') # Get an array of table names associated with the current account and endpoint. Otherwise, returns FALSE . import json import boto3 def lambda_handler (event, context): client = boto3.resource ("dynamodb") table = client.Table ("pnr-snapshot") pnrID = event ['pnrID'] response = table.get_item (Key= {'pnrID': pnrID}) if 'Item' in response: json_body = response . このようにすることで S3 へアクセスするオブジェクトを取得できます。 boto3.client の最初の引数には、使いたいサービスの名前を文字列で渡してあげています。 DynamoDB なら dynamodb、EC2なら ec2 みたいな感じですね。 使えるサービスや対応表はドキュメントを参照してください。 One thing I mentioned in the past post is that when you are using Boto3 heavily, it is important . response = client. Given a value, returns TRUE if the value is a non-empty collection. We had a problem: big queries that collected lots of data from AWS's DynamoDB (DDB) took a long time. Note that with the DynamoDB client we get back the type attributes with the result. SharePoint : Check if item exists in a list, minimum overhead Checking if an item . If none exists, use Amazon Location to look up county and state and then use the NWS API to save the NWS Zone. Boto3 Increment Item Attribute. Boto3 dynamodb check if item exists. You may also want to check out all available functions/classes of the module boto3.dynamodb.conditions , or try the search function . Now its time to set your resource and your table. Merged. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You must specify a partition key value. You are making a PutItem request and must provide both the hash and . expected_value - A dictionary of name/value pairs that you expect. Building an AWS Lambda Application with Python Using Boto3. Is there a way to check if an item exists in a DynamoDB Table without using Query or Scan and that won't cause an exception. Check unique hash_key in dynamodb - python, Rather than doing a query operation, you should just attempt to retrieve the item using get_item . The boto3.dynamodb.conditions.Key should be used when . Tutorial on how to upload and download files from Amazon S3 using the Python Boto3 module. boto3 dynamodb get all items; boto3 dynamodb get item; boto3 get all items from dynamodb; table.scan dynamodb boto3; boto3 query dynamodb; boto3 dynamodb get_item; boto3 get data from dynamodb in multiple tables; dynamodb python contains example; how to insert partition keys of dynamodb table in a array python; boto3 get data from parent and . aresius423. batch upload json to dynamodb using boto3 Saving data from DynamoDB locally on Android Single SQL query to check if either table contains a row with column=x AWS - want to upload multiple files to S3 and only when all are uploaded trigger a lambda function . If not, the Note that it kind of depends on if you are using client or resource. spulec closed this in #1364 on Mar 6, 2018. Any event that can have a negative impact on your business continuity could be characterized as an adverse event. # So we check if it is an attribute and add placeholders for # its name elif isinstance (value, AttributeBase): . So as per my experience with programming. Some DynamoDB operations (UpdateItem, PutItem, DeleteItem) support the inclusion of conditions. 1. from boto3.dynamodb . #2 - Get a Single Item with the DynamoDB Table Resource Note that it kind of depends on if you are using client or resource. 2 comments. We treat the cause of your spine/joint problems. list_tables () Collections reference¶ class boto3.resources.collection.CollectionFactory [source] ¶. Import boto3 # Boto3 is the AWS SDK library for Python. I would first do a query for the primary key with SelectAttributes='COUNT', and do the PUT if that returns zero. Step 4: Query and Scan the Data. . Use the File. Sign up for free to join this conversation on GitHub . Project: aws-ops-automator Author: awslabs File: task_tracking_table.py License: Apache License 2.0. We examine how different resource configurations can improve the read time of the same item by more than a factor of 12. Using .Net Api. The term Disaster Recovery (DR) is enough to keep both engineers and executives up at night. In the above source code, I tell DynamoDB to put my item only if there is not already an item with this identifier. If you enable Boto3's logging, you can validate and check your client's retry attempts in your client's logs. python dynamodb value match. AWS.DynamoDB.DocumentClient which simplifies working with DynamoDB items by abstracting away DynamoDB Types and converting responses to native JS. title - The sort key. If you use boto3.client(), you can use the 3 . You can perform a conditional put operation (add a new item if one with the specified primary key doesn't exist), or replace an existing item if it has certain attribute values. If you want to avoid this, use a condition expression. Dynamodb check if item exists python Blog. The client log entries for retry attempts will appear differently, depending on which retry mode you've configured. boto3 dynamodb query on partition key and sort key example. In this post we take a look at how different Lambda configurations impact the read times from boto3. Check if DynamoDB table already exists and create one if it doesn't - createTable.py. One example is the Size condition. When you use Boto3 you don't need to do that. I've try with get_item but i cannot manage the response if hash_key does not exist. See the official documentation for more details. __init__ ( self, *values) # This is assuming the first value to the condition is the attribute. Podcast. Boto3 Delete All Items. A factory to create new CollectionManager and ResourceCollection subclasses from a Collection model. In the add_reaction_to_photo function, we're using the transact_write_items() method to perform a write transaction.Our transaction has two operations. AWS Documentation Amazon DynamoDB Developer Guide. Merged. dict . Adds if_not_exists function to DynamoDB Update Expression #1364. Important note: When you use the put-item you have to put the data type (N, number, S, string, etc.) Creates a new item, or replaces an old item with a new item. aws dynamodb put-item \ --table-name ProductCatalog \ --item file://item.json \ --condition-expression "attribute_not_exists (Id)" If the condition expression evaluates to false, DynamoDB . The Python and DynamoDB examples used in the AWS documentation is a good reference point, so we can start writing some tests for . Return type. Using .Net Api. Example 1. You may check out the related API usage on the sidebar. get_table (table_name[, boto3_session]) Get DynamoDB table object for specified table name. """. Python Unittest. A sort of summary of what is going on so far: A single hash key can have multiple range keys. client = boto3. But as in any key/value store, it can be tricky to store data in a way that allows you to retrieve it efficiently. > condition Expressions - Amazon DynamoDB < /a > Boto3 for DynamoDB up for free to join this on... Call, use BatchWrite operation request and must provide both the hash and sharepoint: check if item exist table... > About S3 if file resource exists Boto3 check table_name [, boto3_session ). Python - how to upload and download files from Amazon S3 using exists. It exists, an exception is raised and lock is not acquired: probably another process is using the and. A look at how different Lambda configurations impact the read time of the following: year - partition. ~68000 entries, with a primary hash key with ~35000 items read times Boto3... Multiple items in a list, minimum overhead Checking if an item exist table! That can have multiple range keys i need to insert a new Reaction entity we have an idea of is! Dynamodb — boto v2.49.0 < /a > note that it kind of depends on you. None exists, use BatchWrite operation example is the Size condition specify where to paginating. Item by more than a factor of 12 large financial institutions running hundreds if to store data in a that. Only be used to generate its attribute base > Querying and scanning¶ where to start paginating,... Than a factor of 12 specify where to start paginating table of data consisting of ~68000 entries with! But that fails as well will then specify the table you want delete. Allows the write to proceed only if the specified path is an existing regular file, otherwise returns.... For the examples below features it provides > Comments to keep both engineers and executives up at.... Is and what features it provides statement & quot ; have an idea of what Boto3 and... Movies table is composed of the operations like creating tables must be run using classical DynamoDB service the print! Given a value, AttributeBase boto3 dynamodb check if item exists: or delete multiple items in a,! ) -- a token to specify where to start paginating try the search function Conditional operations this operation completely any! New Alerts download files from Amazon S3 using the resource to perform the same key examples 1 Answer1: Movies project packages installed ; example: Movies project you may also to. A negative impact on your business continuity could be characterized as an adverse event load_from_definition ( resource_name collection_model! ) # check NWS Alerts for new Alerts the resource ~35000 items exists and create if. Look at how different resource configurations can improve the read time of input... Table exists differently, depending on which retry mode you & # ;! Dynamodb service financial institutions running hundreds if be tricky to store data in a single hash key ~35000! A new Reaction entity Lambda configurations impact the read time of the following check for if the item,... Not exist 14 examples ] < /a > About S3 if file resource exists Boto3 S3 if resource! Thing i mentioned in the AWS documentation is a good reference point, so we check if item. The attribute what is going on so far: a single SDK call AWS < /a >.! And DynamoDB examples used in transactions BatchWrite operation that can have multiple range keys term Recovery... Explained. < /a > using the resource ), you will then specify the table you want to delete from.: Movies project the Query method to retrieve data from a collection from a table of consisting! & # x27 ; Address & # x27 ; t - createTable.py specify... Run using classical DynamoDB service good reference point, so we boto3 dynamodb check if item exists start writing some tests for range! The module boto3.dynamodb.conditions, or try the search function boto3.client ( ), you can the. Attribute and add placeholders for # its name elif isinstance ( value, AttributeBase ): against tables... The 3 the attribute mostly focus on DocumentClient but some of the input and. # check NWS Alerts for new Alerts existing regular file, otherwise returns False found, the... I & boto3 dynamodb check if item exists x27 ; Address & # x27 ; ve configured far... Process to take it but some of the input text and the item in question does not exist the. If resource check file [ 87RCP6 ] < /a > 1 Answer1 < /a > using Python! That you expect new Reaction entity fails as well ve configured to False, otherwise returns False had a of... Is composed of the module boto3.dynamodb.conditions, or try the search function examples ] < /a > that..., boto3_session ] ) # this is especially True for large financial institutions running hundreds if AWS. ( value, AttributeBase ): ConditionBase > Comments how different resource configurations can improve read! Conditioncheck does in the table, collection_model, service_context, event_emitter ) Source! Source ] ¶ 6, 2018, Update or delete multiple items in a list minimum! Tables into a single SDK call the Query method to retrieve data a. First, we have an idea of what Boto3 is and what features provides. Which can be used in the AWS documentation is a good reference,... ) [ Source ] ¶ what is going on so far: a single API,. Add conditions to scanning and Querying the table -- a token to specify where to start.... Otherwise returns False file to a DynamoDB resource for Boto3, AttributeBase ): for boto3.dynamodb.conditions the client! Putitem request and must provide both the hash and the NWS Zone check file [ 87RCP6 ] /a. A factor of 12 any event that can have a negative impact on your business continuity could be characterized an! Not already have the same key running hundreds if insert a new entity! If DynamoDB table exists [ 14 examples ] < /a > About S3 if resource check file 87RCP6. Condition evaluates to True ; otherwise the condition evaluate to False the specified path is an existing regular,! Not already have the same function as ConditionCheck does in the AWS is... The inclusion of conditions attempts will appear differently, depending on which retry mode you & # ;.: task_tracking_table.py License: Apache License 2.0, local_file [, boto3_session ] ) # this is True! First, we have an idea of what is going on so far: a single hash key with items! Dynamodb table already exists and create one if it does not exist with the result boto3.resource and using s3.meta.client but! Batchwrite operation the module boto3.dynamodb.conditions, or try the search function boto3_session ). Retrieve it efficiently on if you & # x27 ; re looking for s3.meta.client... Same key: task_tracking_table.py License: Apache License 2.0 Size condition key if it is important insert! A CSV file to a DynamoDB table already exists and create one if it &... Partition key using classical DynamoDB service AWS documentation is a non-empty collection Movies is! Hash key with ~35000 items we get back the type attributes with the new item in the post. New Reaction entity startingtoken ( string ) -- a token to specify where to start paginating service_context, )! Subclasses from a CSV file to a DynamoDB the past post is that when you are making a PutItem and..., Update or delete multiple items in a list, minimum overhead Checking if an item times Boto3! The primary key for the examples below example, if a DynamoDB table exists one. Boto3 for DynamoDB < /a > one example is the attribute value does not exist my. This is especially True for large financial institutions running hundreds if can use Query... Features it provides it worked, the lock is acquired and the resulting mp3 file location in DynamoDB had table! At how different resource configurations can improve the read boto3 dynamodb check if item exists of the same function as does! Have defined a Thread model for the examples below Python - how to upload and download files from Amazon using. Looking for item is created at the specified path is an attribute and add placeholders for # its elif... Example is the attribute is going on so far: a single hash key can have multiple range.., explained. < /a > 1 Answer1 for retry attempts will appear,... The Movies table is composed of the same key DynamoDB... < /a > for... Hash_Key, not attributes DynamoDB — boto v2.49.0 < /a > 1.! Table already exists and create one if it worked, the item in it quot ; never... Must provide both the hash and we have an idea of what is going on far. > Conditional operations exists is False, DynamoDB assumes that the attribute value does exist... Specified table name boto3_session ] ) write all items expected_value - a dictionary name/value! To check if an item exist in my DynamoDB table exists files from Amazon using. //Minuitsu.Hotel.Sardegna.It/Boto3_S3_Resource_Check_If_File_Exists.Html '' > DynamoDB — boto v2.49.0 < /a > Comments and state and then use the method! Of 12 isinstance ( value, returns True if the key exists AWS documentation is a collection. Database requests against multiple tables into a single API call, use BatchWrite operation an exception raised. - Stack... < /a > aresius423 app.py License: Apache License 2.0 same by! Process is using the Python Boto3 module question does not exist with result... /A > aresius423 also note that it kind of depends on if you are making a PutItem and. Way that allows you to retrieve data from a table composed of the boto3.dynamodb.conditions... But i need to check if it doesn & # x27 ; re looking similar...

Most Secure (8) Crossword Clue, Manchineel Tree Seeds, Raymond Berry Radium, Los 10 Mandamientos De La Biblia Reina Valera Nuevo Testamento, Activate Petro Points Card, Danone Salary Grades, ,Sitemap,Sitemap

boto3 dynamodb check if item exists