Skip to content

Commit d279831

Browse files
committed
fix doc
1 parent c2a16f0 commit d279831

File tree

7 files changed

+1410
-490
lines changed

7 files changed

+1410
-490
lines changed

docs/source/03-Compressed-Attribute/index.ipynb

+839
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {
6+
"collapsed": false,
7+
"jupyter": {
8+
"outputs_hidden": false
9+
},
10+
"pycharm": {
11+
"name": "#%% md\n"
12+
}
13+
},
14+
"source": [
15+
"# AWS DynamoDB Console Url\n",
16+
"\n",
17+
"This feature can print the AWS DynamoDB console url for the table, items. You can use this in you logging to quickly jump to the console to debug.\n"
18+
]
19+
},
20+
{
21+
"cell_type": "code",
22+
"execution_count": 1,
23+
"metadata": {
24+
"ExecuteTime": {
25+
"end_time": "2024-05-22T20:12:23.493151Z",
26+
"start_time": "2024-05-22T20:12:23.347291Z"
27+
},
28+
"collapsed": false,
29+
"jupyter": {
30+
"outputs_hidden": false
31+
},
32+
"pycharm": {
33+
"name": "#%%\n"
34+
}
35+
},
36+
"outputs": [
37+
{
38+
"data": {
39+
"text/html": [
40+
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">table overview: \n",
41+
"<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://us-east-1.console.aws.amazon.com/dynamodbv2/home?region=us-east-1#table?initialTagKey=&amp;name=pynamodb-mate-e</span>\n",
42+
"<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">xample-console-model1&amp;tab=overview</span>\n",
43+
"</pre>\n"
44+
],
45+
"text/plain": [
46+
"table overview: \n",
47+
"\u001b[4;94mhttps://us-east-1.console.aws.amazon.com/dynamodbv2/home?\u001b[0m\u001b[4;94mregion\u001b[0m\u001b[4;94m=\u001b[0m\u001b[4;94mus\u001b[0m\u001b[4;94m-east-1#table?\u001b[0m\u001b[4;94minitialTagKey\u001b[0m\u001b[4;94m=&\u001b[0m\u001b[4;94mname\u001b[0m\u001b[4;94m=\u001b[0m\u001b[4;94mpynamodb\u001b[0m\u001b[4;94m-mate-e\u001b[0m\n",
48+
"\u001b[4;94mxample-console-model1&\u001b[0m\u001b[4;94mtab\u001b[0m\u001b[4;94m=\u001b[0m\u001b[4;94moverview\u001b[0m\n"
49+
]
50+
},
51+
"metadata": {},
52+
"output_type": "display_data"
53+
},
54+
{
55+
"data": {
56+
"text/html": [
57+
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">view items in table: \n",
58+
"<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://us-east-1.console.aws.amazon.com/dynamodbv2/home?region=us-east-1#item-explorer?initialTagKey=&amp;maximize=tru</span>\n",
59+
"<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">e&amp;table=pynamodb-mate-example-console-model1</span>\n",
60+
"</pre>\n"
61+
],
62+
"text/plain": [
63+
"view items in table: \n",
64+
"\u001b[4;94mhttps://us-east-1.console.aws.amazon.com/dynamodbv2/home?\u001b[0m\u001b[4;94mregion\u001b[0m\u001b[4;94m=\u001b[0m\u001b[4;94mus\u001b[0m\u001b[4;94m-east-1#item-explorer?\u001b[0m\u001b[4;94minitialTagKey\u001b[0m\u001b[4;94m=&\u001b[0m\u001b[4;94mmaximize\u001b[0m\u001b[4;94m=\u001b[0m\u001b[4;94mtru\u001b[0m\n",
65+
"\u001b[4;94me\u001b[0m\u001b[4;94m&\u001b[0m\u001b[4;94mtable\u001b[0m\u001b[4;94m=\u001b[0m\u001b[4;94mpynamodb\u001b[0m\u001b[4;94m-mate-example-console-model1\u001b[0m\n"
66+
]
67+
},
68+
"metadata": {},
69+
"output_type": "display_data"
70+
},
71+
{
72+
"data": {
73+
"text/html": [
74+
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">view item details: \n",
75+
"<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://us-east-1.console.aws.amazon.com/dynamodbv2/home?region=us-east-1#edit-item?table=pynamodb-mate-example-con</span>\n",
76+
"<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">sole-model1&amp;itemMode=2&amp;pk=a&amp;sk&amp;ref=%23item-explorer%3Ftable%3Dpynamodb-mate-example-console-model1&amp;route=ROUTE_ITEM</span>\n",
77+
"<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">_EXPLORER</span>\n",
78+
"</pre>\n"
79+
],
80+
"text/plain": [
81+
"view item details: \n",
82+
"\u001b[4;94mhttps://us-east-1.console.aws.amazon.com/dynamodbv2/home?\u001b[0m\u001b[4;94mregion\u001b[0m\u001b[4;94m=\u001b[0m\u001b[4;94mus\u001b[0m\u001b[4;94m-east-1#edit-item?\u001b[0m\u001b[4;94mtable\u001b[0m\u001b[4;94m=\u001b[0m\u001b[4;94mpynamodb\u001b[0m\u001b[4;94m-mate-example-con\u001b[0m\n",
83+
"\u001b[4;94msole-model1&\u001b[0m\u001b[4;94mitemMode\u001b[0m\u001b[4;94m=\u001b[0m\u001b[4;94m2\u001b[0m\u001b[4;94m&\u001b[0m\u001b[4;94mpk\u001b[0m\u001b[4;94m=\u001b[0m\u001b[4;94ma\u001b[0m\u001b[4;94m&sk&\u001b[0m\u001b[4;94mref\u001b[0m\u001b[4;94m=%23item-explorer%3Ftable%3Dpynamodb-mate-example-console-model1&\u001b[0m\u001b[4;94mroute\u001b[0m\u001b[4;94m=\u001b[0m\u001b[4;94mROUTE_ITEM\u001b[0m\n",
84+
"\u001b[4;94m_EXPLORER\u001b[0m\n"
85+
]
86+
},
87+
"metadata": {},
88+
"output_type": "display_data"
89+
}
90+
],
91+
"source": [
92+
"# This example is about a table doesn't have range key\n",
93+
"from rich import print as rprint\n",
94+
"from datetime import datetime, timezone\n",
95+
"import pynamodb_mate.api as pm\n",
96+
"\n",
97+
"class Model1(pm.Model):\n",
98+
" class Meta:\n",
99+
" table_name = f\"pynamodb-mate-example-console-model1\"\n",
100+
" region = \"us-east-1\"\n",
101+
" billing_mode = pm.constants.PAY_PER_REQUEST_BILLING_MODE\n",
102+
"\n",
103+
" hash_key = pm.UnicodeAttribute(hash_key=True)\n",
104+
" data = pm.JSONAttribute(default=lambda: dict())\n",
105+
"\n",
106+
"model1 = Model1(hash_key=\"a\")\n",
107+
"\n",
108+
"rprint(f\"table overview: {Model1.get_table_overview_console_url()}\")\n",
109+
"rprint(f\"view items in table: {Model1.get_table_items_console_url()}\")\n",
110+
"rprint(f\"view item details: {model1.item_detail_console_url}\")"
111+
]
112+
},
113+
{
114+
"cell_type": "code",
115+
"execution_count": 2,
116+
"metadata": {
117+
"ExecuteTime": {
118+
"end_time": "2024-05-22T20:12:53.627351Z",
119+
"start_time": "2024-05-22T20:12:53.622667Z"
120+
},
121+
"collapsed": false,
122+
"jupyter": {
123+
"outputs_hidden": false
124+
},
125+
"pycharm": {
126+
"name": "#%%\n"
127+
}
128+
},
129+
"outputs": [
130+
{
131+
"data": {
132+
"text/html": [
133+
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">table overview: \n",
134+
"<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://us-east-1.console.aws.amazon.com/dynamodbv2/home?region=us-east-1#table?initialTagKey=&amp;name=pynamodb-mate-e</span>\n",
135+
"<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">xample-console-model2&amp;tab=overview</span>\n",
136+
"</pre>\n"
137+
],
138+
"text/plain": [
139+
"table overview: \n",
140+
"\u001b[4;94mhttps://us-east-1.console.aws.amazon.com/dynamodbv2/home?\u001b[0m\u001b[4;94mregion\u001b[0m\u001b[4;94m=\u001b[0m\u001b[4;94mus\u001b[0m\u001b[4;94m-east-1#table?\u001b[0m\u001b[4;94minitialTagKey\u001b[0m\u001b[4;94m=&\u001b[0m\u001b[4;94mname\u001b[0m\u001b[4;94m=\u001b[0m\u001b[4;94mpynamodb\u001b[0m\u001b[4;94m-mate-e\u001b[0m\n",
141+
"\u001b[4;94mxample-console-model2&\u001b[0m\u001b[4;94mtab\u001b[0m\u001b[4;94m=\u001b[0m\u001b[4;94moverview\u001b[0m\n"
142+
]
143+
},
144+
"metadata": {},
145+
"output_type": "display_data"
146+
},
147+
{
148+
"data": {
149+
"text/html": [
150+
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">view items in table: \n",
151+
"<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://us-east-1.console.aws.amazon.com/dynamodbv2/home?region=us-east-1#item-explorer?initialTagKey=&amp;maximize=tru</span>\n",
152+
"<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">e&amp;table=pynamodb-mate-example-console-model2</span>\n",
153+
"</pre>\n"
154+
],
155+
"text/plain": [
156+
"view items in table: \n",
157+
"\u001b[4;94mhttps://us-east-1.console.aws.amazon.com/dynamodbv2/home?\u001b[0m\u001b[4;94mregion\u001b[0m\u001b[4;94m=\u001b[0m\u001b[4;94mus\u001b[0m\u001b[4;94m-east-1#item-explorer?\u001b[0m\u001b[4;94minitialTagKey\u001b[0m\u001b[4;94m=&\u001b[0m\u001b[4;94mmaximize\u001b[0m\u001b[4;94m=\u001b[0m\u001b[4;94mtru\u001b[0m\n",
158+
"\u001b[4;94me\u001b[0m\u001b[4;94m&\u001b[0m\u001b[4;94mtable\u001b[0m\u001b[4;94m=\u001b[0m\u001b[4;94mpynamodb\u001b[0m\u001b[4;94m-mate-example-console-model2\u001b[0m\n"
159+
]
160+
},
161+
"metadata": {},
162+
"output_type": "display_data"
163+
},
164+
{
165+
"data": {
166+
"text/html": [
167+
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">view item details: \n",
168+
"<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">https://us-east-1.console.aws.amazon.com/dynamodbv2/home?region=us-east-1#edit-item?table=pynamodb-mate-example-con</span>\n",
169+
"<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">sole-model2&amp;itemMode=2&amp;pk=a&amp;sk=2000-01-01T00:00:00.000000+0000&amp;ref=%23item-explorer%3Ftable%3Dpynamodb-mate-example</span>\n",
170+
"<span style=\"color: #0000ff; text-decoration-color: #0000ff; text-decoration: underline\">-console-model2&amp;route=ROUTE_ITEM_EXPLORER</span>\n",
171+
"</pre>\n"
172+
],
173+
"text/plain": [
174+
"view item details: \n",
175+
"\u001b[4;94mhttps://us-east-1.console.aws.amazon.com/dynamodbv2/home?\u001b[0m\u001b[4;94mregion\u001b[0m\u001b[4;94m=\u001b[0m\u001b[4;94mus\u001b[0m\u001b[4;94m-east-1#edit-item?\u001b[0m\u001b[4;94mtable\u001b[0m\u001b[4;94m=\u001b[0m\u001b[4;94mpynamodb\u001b[0m\u001b[4;94m-mate-example-con\u001b[0m\n",
176+
"\u001b[4;94msole-model2&\u001b[0m\u001b[4;94mitemMode\u001b[0m\u001b[4;94m=\u001b[0m\u001b[4;94m2\u001b[0m\u001b[4;94m&\u001b[0m\u001b[4;94mpk\u001b[0m\u001b[4;94m=\u001b[0m\u001b[4;94ma\u001b[0m\u001b[4;94m&\u001b[0m\u001b[4;94msk\u001b[0m\u001b[4;94m=\u001b[0m\u001b[4;94m2000\u001b[0m\u001b[4;94m-01-01T00:00:00.000000+0000&\u001b[0m\u001b[4;94mref\u001b[0m\u001b[4;94m=%23item-explorer%3Ftable%3Dpynamodb-mate-example\u001b[0m\n",
177+
"\u001b[4;94m-console-model2&\u001b[0m\u001b[4;94mroute\u001b[0m\u001b[4;94m=\u001b[0m\u001b[4;94mROUTE_ITEM_EXPLORER\u001b[0m\n"
178+
]
179+
},
180+
"metadata": {},
181+
"output_type": "display_data"
182+
}
183+
],
184+
"source": [
185+
"# This example is about a table has both hash key and range key\n",
186+
"class Model2(pm.Model):\n",
187+
" class Meta:\n",
188+
" table_name = f\"pynamodb-mate-example-console-model2\"\n",
189+
" region = \"us-east-1\"\n",
190+
" billing_mode = pm.constants.PAY_PER_REQUEST_BILLING_MODE\n",
191+
"\n",
192+
" hash_key = pm.UnicodeAttribute(hash_key=True)\n",
193+
" range_key = pm.UTCDateTimeAttribute(range_key=True)\n",
194+
" data = pm.JSONAttribute(default=lambda: dict())\n",
195+
"\n",
196+
"model2 = Model2(\n",
197+
" hash_key=\"a\",\n",
198+
" range_key=datetime(2000, 1, 1, tzinfo=timezone.utc),\n",
199+
")\n",
200+
"\n",
201+
"rprint(f\"table overview: {Model2.get_table_overview_console_url()}\")\n",
202+
"rprint(f\"view items in table: {Model2.get_table_items_console_url()}\")\n",
203+
"rprint(f\"view item details: {model2.item_detail_console_url}\")"
204+
]
205+
},
206+
{
207+
"cell_type": "code",
208+
"execution_count": null,
209+
"metadata": {
210+
"collapsed": false,
211+
"jupyter": {
212+
"outputs_hidden": false
213+
},
214+
"pycharm": {
215+
"name": "#%%\n"
216+
}
217+
},
218+
"outputs": [],
219+
"source": []
220+
}
221+
],
222+
"metadata": {
223+
"kernelspec": {
224+
"display_name": "Python 3 (ipykernel)",
225+
"language": "python",
226+
"name": "python3"
227+
},
228+
"language_info": {
229+
"codemirror_mode": {
230+
"name": "ipython",
231+
"version": 3
232+
},
233+
"file_extension": ".py",
234+
"mimetype": "text/x-python",
235+
"name": "python",
236+
"nbconvert_exporter": "python",
237+
"pygments_lexer": "ipython3",
238+
"version": "3.8.13"
239+
}
240+
},
241+
"nbformat": 4,
242+
"nbformat_minor": 4
243+
}

0 commit comments

Comments
 (0)