C2 Week 1 Practice Lab 2
Interacting With Amazon DynamoDB NoSQL Database
I can’t create the ProductCatalog Table
THIS
response=create_table_db…
Now that the create_table_db()
function is ready, you can test it by creating the ProductCatalog
table. The execution should take less than a minute.
Hello @Alex999,
Could you check the solutions, maybe there is something wrong with Exercise 1 in the create_table_db
function. Since it’s a practice lab you could post your code or any errors. Hope it helps
Georgios, Hi
I’ve checked everything imaginable.And the Solutions didn’t help – it had issues of its own. At this point, I’d appreciate someone just giving me the answer – then I can l see what my error(s) is.
Thanks
Alex
Hello @Alex999,
Sorry for the inconvenience and the issue you are facing. I couldn’t reproduce the issue and could create ProductCatalog with the code cell. If you could post a screenshot of your output would help. Perhaps we can see someone more comfortable with dynamodb. Thanks
Georgios, Hi
I asked for someone to post the correct code. Please post you code since you said it worked
Thanks
Alex
Hello @Alex999
To open the solution notebook, follow these steps:
-
Go to the main menu and select File -> Preferences -> Settings
.
-
Click on Text Editor
on the left, then scroll down to the Files: Exclude
section.
-
Remove the line **/C2_W1_Lab_2_DynamoDB_Solution.ipynb
. The file will now appear in the explorer.
-
You can close the Settings
tab.
And this is my code:
def create_table_db(table_name: str, **kwargs):
client = boto3.client("dynamodb")
### START CODE HERE ### (~ 1 line of code)
response = client.create_table(TableName=None, None)
### END CODE HERE ###
waiter = client.get_waiter("table_exists")
waiter.wait(TableName=table_name)
return response
To create the table we use this code:
response = create_table_db(table_name=product_catalog_table['table_name'], **product_catalog_table["kwargs"])
print(response)
If you get an invalid endpoint instead of the expected output go to help and reboot:
Finally you get the expected output:
Giorgios, Hi
Rebooted
Used your code
Two error messages
TypeError: unhashable type: ‘dict’[‘kwargs’])
Cell In[7], line 5
** TypeError: unhashable type: ‘dict’[‘kwargs’])**
** ^**
SyntaxError: unmatched ')’
Thanks
Alex
Hello @Alex999,
Could you get a fresh notebook with these instructions:
-
Rename your existing notebook, right click > rename:
-
Click help like before and get latest version:
You should have a new notebook and post any screenshots of errors.
Thanks