Skip to content

Commit 32bf2d1

Browse files
author
Penta, Antonio
committed
add example to query template
1 parent b58ae8e commit 32bf2d1

File tree

1 file changed

+111
-15
lines changed

1 file changed

+111
-15
lines changed

TemplateToRunQuery.ipynb

Lines changed: 111 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 4,
5+
"execution_count": 1,
66
"metadata": {},
77
"outputs": [
88
{
@@ -21,25 +21,16 @@
2121
},
2222
{
2323
"cell_type": "code",
24-
"execution_count": 5,
24+
"execution_count": 2,
2525
"metadata": {},
26-
"outputs": [
27-
{
28-
"name": "stdout",
29-
"output_type": "stream",
30-
"text": [
31-
"The sql extension is already loaded. To reload it, use:\n",
32-
" %reload_ext sql\n"
33-
]
34-
}
35-
],
26+
"outputs": [],
3627
"source": [
3728
"%load_ext sql "
3829
]
3930
},
4031
{
4132
"cell_type": "code",
42-
"execution_count": 6,
33+
"execution_count": 3,
4334
"metadata": {},
4435
"outputs": [
4536
{
@@ -134,7 +125,7 @@
134125
" ('9', '11987', '144', '1 oz')]"
135126
]
136127
},
137-
"execution_count": 6,
128+
"execution_count": 3,
138129
"metadata": {},
139130
"output_type": "execute_result"
140131
}
@@ -144,12 +135,117 @@
144135
"select * from composition limit 10"
145136
]
146137
},
138+
{
139+
"cell_type": "code",
140+
"execution_count": 4,
141+
"metadata": {},
142+
"outputs": [
143+
{
144+
"name": "stdout",
145+
"output_type": "stream",
146+
"text": [
147+
" * postgresql://antoniopenta:***@goldsmith.clb2mudtmvnt.eu-central-1.rds.amazonaws.com:5432/goldsmiths\n",
148+
"5 rows affected.\n"
149+
]
150+
},
151+
{
152+
"data": {
153+
"text/html": [
154+
"<table>\n",
155+
" <tr>\n",
156+
" <th>stralcoholic</th>\n",
157+
" </tr>\n",
158+
" <tr>\n",
159+
" <td>None</td>\n",
160+
" </tr>\n",
161+
" <tr>\n",
162+
" <td>Alcoholic</td>\n",
163+
" </tr>\n",
164+
" <tr>\n",
165+
" <td>Optional alcohol</td>\n",
166+
" </tr>\n",
167+
" <tr>\n",
168+
" <td>Non alcoholic</td>\n",
169+
" </tr>\n",
170+
" <tr>\n",
171+
" <td>Non Alcoholic</td>\n",
172+
" </tr>\n",
173+
"</table>"
174+
],
175+
"text/plain": [
176+
"[(None,),\n",
177+
" ('Alcoholic',),\n",
178+
" ('Optional alcohol',),\n",
179+
" ('Non alcoholic',),\n",
180+
" ('Non Alcoholic',)]"
181+
]
182+
},
183+
"execution_count": 4,
184+
"metadata": {},
185+
"output_type": "execute_result"
186+
}
187+
],
188+
"source": [
189+
"%sql select distinct stralcoholic from cocktail;"
190+
]
191+
},
192+
{
193+
"cell_type": "code",
194+
"execution_count": 5,
195+
"metadata": {},
196+
"outputs": [
197+
{
198+
"name": "stdout",
199+
"output_type": "stream",
200+
"text": [
201+
" * postgresql://antoniopenta:***@goldsmith.clb2mudtmvnt.eu-central-1.rds.amazonaws.com:5432/goldsmiths\n",
202+
"5 rows affected.\n",
203+
"+------------------+\n",
204+
"| stralcoholic |\n",
205+
"+------------------+\n",
206+
"| None |\n",
207+
"| Alcoholic |\n",
208+
"| Optional alcohol |\n",
209+
"| Non alcoholic |\n",
210+
"| Non Alcoholic |\n",
211+
"+------------------+\n"
212+
]
213+
}
214+
],
215+
"source": [
216+
"result = %sql select distinct stralcoholic from cocktail;\n",
217+
"print(result)"
218+
]
219+
},
220+
{
221+
"cell_type": "code",
222+
"execution_count": 6,
223+
"metadata": {},
224+
"outputs": [
225+
{
226+
"name": "stdout",
227+
"output_type": "stream",
228+
"text": [
229+
" * postgresql://antoniopenta:***@goldsmith.clb2mudtmvnt.eu-central-1.rds.amazonaws.com:5432/goldsmiths\n",
230+
"5 rows affected.\n",
231+
"['stralcoholic']\n"
232+
]
233+
}
234+
],
235+
"source": [
236+
"result = %sql select distinct stralcoholic from cocktail;\n",
237+
"print(result.keys)"
238+
]
239+
},
147240
{
148241
"cell_type": "code",
149242
"execution_count": null,
150243
"metadata": {},
151244
"outputs": [],
152-
"source": []
245+
"source": [
246+
"result = %sql select distinct stralcoholic from cocktail;\n",
247+
"df=pd."
248+
]
153249
}
154250
],
155251
"metadata": {

0 commit comments

Comments
 (0)