Created
May 9, 2019 01:10
-
-
Save mde-2590/402363633dcb56da6040c2e22ece14dd to your computer and use it in GitHub Desktop.
Created on Cognitive Class Labs
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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"#Below, we'll use the load_ext magic to load the ipython-sql extension. \n", | |
"\n", | |
"%load_ext sql" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"'Connected: dfk30111@BLUDB'" | |
] | |
}, | |
"execution_count": 2, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"# Enter your Db2 credentials in the connection string below\n", | |
"# Recall you created Service Credentials in Part III of the first lab of the course in Week 1\n", | |
"# i.e. from the uri field in the Service Credentials copy everything after db2:// (but remove the double quote at the end)\n", | |
"# for example, if your credentials are as in the screenshot above, you would write:\n", | |
"# %sql ibm_db_sa://my-username:[email protected]:50000/BLUDB\n", | |
"# Note the ibm_db_sa:// prefix instead of db2://\n", | |
"# This is because JupyterLab's ipython-sql extension uses sqlalchemy (a python SQL toolkit)\n", | |
"# which in turn uses IBM's sqlalchemy dialect: ibm_db_sa\n", | |
"\n", | |
"%sql ibm_db_sa://dfk30111:b6q01rtcjz%[email protected]:50000/BLUDB" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"#Use %%sql (two %'s instead of one) at the top of a cell to indicate we want the entire cell to be treated as SQL. Let's use this to create a table and fill it with some test data for experimenting" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" * ibm_db_sa://dfk30111:***@dashdb-txn-sbox-yp-dal09-04.services.dal.bluemix.net:50000/BLUDB\n", | |
"Done.\n", | |
"99 rows affected.\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"[]" | |
] | |
}, | |
"execution_count": 13, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"%%sql\n", | |
"\n", | |
"CREATE TABLE INTERNATIONAL_STUDENT_TEST_SCORES (\n", | |
"\tcountry VARCHAR(50),\n", | |
"\tfirst_name VARCHAR(50),\n", | |
"\tlast_name VARCHAR(50),\n", | |
"\ttest_score INT\n", | |
");\n", | |
"INSERT INTO INTERNATIONAL_STUDENT_TEST_SCORES (country, first_name, last_name, test_score)\n", | |
"VALUES\n", | |
"('United States', 'Marshall', 'Bernadot', 54),\n", | |
"('Ghana', 'Celinda', 'Malkin', 51),\n", | |
"('Ukraine', 'Guillermo', 'Furze', 53),\n", | |
"('Greece', 'Aharon', 'Tunnow', 48),\n", | |
"('Russia', 'Bail', 'Goodwin', 46),\n", | |
"('Poland', 'Cole', 'Winteringham', 49),\n", | |
"('Sweden', 'Emlyn', 'Erricker', 55),\n", | |
"('Russia', 'Cathee', 'Sivewright', 49),\n", | |
"('China', 'Barny', 'Ingerson', 57),\n", | |
"('Uganda', 'Sharla', 'Papaccio', 55),\n", | |
"('China', 'Stella', 'Youens', 51),\n", | |
"('Poland', 'Julio', 'Buesden', 48),\n", | |
"('United States', 'Tiffie', 'Cosely', 58),\n", | |
"('Poland', 'Auroora', 'Stiffell', 45),\n", | |
"('China', 'Clarita', 'Huet', 52),\n", | |
"('Poland', 'Shannon', 'Goulden', 45),\n", | |
"('Philippines', 'Emylee', 'Privost', 50),\n", | |
"('France', 'Madelina', 'Burk', 49),\n", | |
"('China', 'Saunderson', 'Root', 58),\n", | |
"('Indonesia', 'Bo', 'Waring', 55),\n", | |
"('China', 'Hollis', 'Domotor', 45),\n", | |
"('Russia', 'Robbie', 'Collip', 46),\n", | |
"('Philippines', 'Davon', 'Donisi', 46),\n", | |
"('China', 'Cristabel', 'Radeliffe', 48),\n", | |
"('China', 'Wallis', 'Bartleet', 58),\n", | |
"('Moldova', 'Arleen', 'Stailey', 38),\n", | |
"('Ireland', 'Mendel', 'Grumble', 58),\n", | |
"('China', 'Sallyann', 'Exley', 51),\n", | |
"('Mexico', 'Kain', 'Swaite', 46),\n", | |
"('Indonesia', 'Alonso', 'Bulteel', 45),\n", | |
"('Armenia', 'Anatol', 'Tankus', 51),\n", | |
"('Indonesia', 'Coralyn', 'Dawkins', 48),\n", | |
"('China', 'Deanne', 'Edwinson', 45),\n", | |
"('China', 'Georgiana', 'Epple', 51),\n", | |
"('Portugal', 'Bartlet', 'Breese', 56),\n", | |
"('Azerbaijan', 'Idalina', 'Lukash', 50),\n", | |
"('France', 'Livvie', 'Flory', 54),\n", | |
"('Malaysia', 'Nonie', 'Borit', 48),\n", | |
"('Indonesia', 'Clio', 'Mugg', 47),\n", | |
"('Brazil', 'Westley', 'Measor', 48),\n", | |
"('Philippines', 'Katrinka', 'Sibbert', 51),\n", | |
"('Poland', 'Valentia', 'Mounch', 50),\n", | |
"('Norway', 'Sheilah', 'Hedditch', 53),\n", | |
"('Papua New Guinea', 'Itch', 'Jubb', 50),\n", | |
"('Latvia', 'Stesha', 'Garnson', 53),\n", | |
"('Canada', 'Cristionna', 'Wadmore', 46),\n", | |
"('China', 'Lianna', 'Gatward', 43),\n", | |
"('Guatemala', 'Tanney', 'Vials', 48),\n", | |
"('France', 'Alma', 'Zavittieri', 44),\n", | |
"('China', 'Alvira', 'Tamas', 50),\n", | |
"('United States', 'Shanon', 'Peres', 45),\n", | |
"('Sweden', 'Maisey', 'Lynas', 53),\n", | |
"('Indonesia', 'Kip', 'Hothersall', 46),\n", | |
"('China', 'Cash', 'Landis', 48),\n", | |
"('Panama', 'Kennith', 'Digance', 45),\n", | |
"('China', 'Ulberto', 'Riggeard', 48),\n", | |
"('Switzerland', 'Judy', 'Gilligan', 49),\n", | |
"('Philippines', 'Tod', 'Trevaskus', 52),\n", | |
"('Brazil', 'Herold', 'Heggs', 44),\n", | |
"('Latvia', 'Verney', 'Note', 50),\n", | |
"('Poland', 'Temp', 'Ribey', 50),\n", | |
"('China', 'Conroy', 'Egdal', 48),\n", | |
"('Japan', 'Gabie', 'Alessandone', 47),\n", | |
"('Ukraine', 'Devlen', 'Chaperlin', 54),\n", | |
"('France', 'Babbette', 'Turner', 51),\n", | |
"('Czech Republic', 'Virgil', 'Scotney', 52),\n", | |
"('Tajikistan', 'Zorina', 'Bedow', 49),\n", | |
"('China', 'Aidan', 'Rudeyeard', 50),\n", | |
"('Ireland', 'Saunder', 'MacLice', 48),\n", | |
"('France', 'Waly', 'Brunstan', 53),\n", | |
"('China', 'Gisele', 'Enns', 52),\n", | |
"('Peru', 'Mina', 'Winchester', 48),\n", | |
"('Japan', 'Torie', 'MacShirrie', 50),\n", | |
"('Russia', 'Benjamen', 'Kenford', 51),\n", | |
"('China', 'Etan', 'Burn', 53),\n", | |
"('Russia', 'Merralee', 'Chaperlin', 38),\n", | |
"('Indonesia', 'Lanny', 'Malam', 49),\n", | |
"('Canada', 'Wilhelm', 'Deeprose', 54),\n", | |
"('Czech Republic', 'Lari', 'Hillhouse', 48),\n", | |
"('China', 'Ossie', 'Woodley', 52),\n", | |
"('Macedonia', 'April', 'Tyer', 50),\n", | |
"('Vietnam', 'Madelon', 'Dansey', 53),\n", | |
"('Ukraine', 'Korella', 'McNamee', 52),\n", | |
"('Jamaica', 'Linnea', 'Cannam', 43),\n", | |
"('China', 'Mart', 'Coling', 52),\n", | |
"('Indonesia', 'Marna', 'Causbey', 47),\n", | |
"('China', 'Berni', 'Daintier', 55),\n", | |
"('Poland', 'Cynthia', 'Hassell', 49),\n", | |
"('Canada', 'Carma', 'Schule', 49),\n", | |
"('Indonesia', 'Malia', 'Blight', 48),\n", | |
"('China', 'Paulo', 'Seivertsen', 47),\n", | |
"('Niger', 'Kaylee', 'Hearley', 54),\n", | |
"('Japan', 'Maure', 'Jandak', 46),\n", | |
"('Argentina', 'Foss', 'Feavers', 45),\n", | |
"('Venezuela', 'Ron', 'Leggitt', 60),\n", | |
"('Russia', 'Flint', 'Gokes', 40),\n", | |
"('China', 'Linet', 'Conelly', 52),\n", | |
"('Philippines', 'Nikolas', 'Birtwell', 57),\n", | |
"('Australia', 'Eduard', 'Leipelt', 53)\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"#Using Python Variables in your SQL Statements\n", | |
"#You can use python variables in your SQL statements by adding a \":\" prefix to your python variable names.\n", | |
"#For example, if I have a python variable country with a value of \"Canada\", I can use this variable in a SQL query to find all the rows of students from Canada." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" * ibm_db_sa://dfk30111:***@dashdb-txn-sbox-yp-dal09-04.services.dal.bluemix.net:50000/BLUDB\n", | |
"Done.\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<table>\n", | |
" <tr>\n", | |
" <th>country</th>\n", | |
" <th>first_name</th>\n", | |
" <th>last_name</th>\n", | |
" <th>test_score</th>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>Canada</td>\n", | |
" <td>Cristionna</td>\n", | |
" <td>Wadmore</td>\n", | |
" <td>46</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>Canada</td>\n", | |
" <td>Wilhelm</td>\n", | |
" <td>Deeprose</td>\n", | |
" <td>54</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>Canada</td>\n", | |
" <td>Carma</td>\n", | |
" <td>Schule</td>\n", | |
" <td>49</td>\n", | |
" </tr>\n", | |
"</table>" | |
], | |
"text/plain": [ | |
"[('Canada', 'Cristionna', 'Wadmore', 46),\n", | |
" ('Canada', 'Wilhelm', 'Deeprose', 54),\n", | |
" ('Canada', 'Carma', 'Schule', 49)]" | |
] | |
}, | |
"execution_count": 14, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"country = \"Canada\"\n", | |
"%sql select * from INTERNATIONAL_STUDENT_TEST_SCORES where country = :country" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 15, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"#Assigning the Results of Queries to Python Variables\n", | |
"#You can use the normal python assignment syntax to assign the results of your queries to python variables.\n", | |
"#For example, I have a SQL query to retrieve the distribution of test scores (i.e. how many students got each score). I can assign the result of this query to the variable test_score_distribution using the = operator" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 16, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" * ibm_db_sa://dfk30111:***@dashdb-txn-sbox-yp-dal09-04.services.dal.bluemix.net:50000/BLUDB\n", | |
"Done.\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<table>\n", | |
" <tr>\n", | |
" <th>Test Score</th>\n", | |
" <th>Frequency</th>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>38</td>\n", | |
" <td>2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>40</td>\n", | |
" <td>1</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>43</td>\n", | |
" <td>2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>44</td>\n", | |
" <td>2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>45</td>\n", | |
" <td>8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>46</td>\n", | |
" <td>7</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>47</td>\n", | |
" <td>4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>48</td>\n", | |
" <td>14</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>49</td>\n", | |
" <td>8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>50</td>\n", | |
" <td>10</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>51</td>\n", | |
" <td>8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>52</td>\n", | |
" <td>8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>53</td>\n", | |
" <td>8</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>54</td>\n", | |
" <td>5</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>55</td>\n", | |
" <td>4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>56</td>\n", | |
" <td>1</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>57</td>\n", | |
" <td>2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>58</td>\n", | |
" <td>4</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <td>60</td>\n", | |
" <td>1</td>\n", | |
" </tr>\n", | |
"</table>" | |
], | |
"text/plain": [ | |
"[(38, Decimal('2')),\n", | |
" (40, Decimal('1')),\n", | |
" (43, Decimal('2')),\n", | |
" (44, Decimal('2')),\n", | |
" (45, Decimal('8')),\n", | |
" (46, Decimal('7')),\n", | |
" (47, Decimal('4')),\n", | |
" (48, Decimal('14')),\n", | |
" (49, Decimal('8')),\n", | |
" (50, Decimal('10')),\n", | |
" (51, Decimal('8')),\n", | |
" (52, Decimal('8')),\n", | |
" (53, Decimal('8')),\n", | |
" (54, Decimal('5')),\n", | |
" (55, Decimal('4')),\n", | |
" (56, Decimal('1')),\n", | |
" (57, Decimal('2')),\n", | |
" (58, Decimal('4')),\n", | |
" (60, Decimal('1'))]" | |
] | |
}, | |
"execution_count": 16, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"test_score_distribution = %sql SELECT test_score as \"Test Score\", count(*) as \"Frequency\" from INTERNATIONAL_STUDENT_TEST_SCORES GROUP BY test_score;\n", | |
"test_score_distribution" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 17, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"#Converting Query Results to DataFrames\n", | |
"#You can easily convert a SQL query result to a pandas dataframe using the DataFrame() method. Dataframe objects are much more versatile than SQL query result objects. For example, we can easily graph our test score distribution after converting to a dataframe." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 18, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEKCAYAAAAfGVI8AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAGApJREFUeJzt3XmYJHWd5/H3B1oUFESlOBTbVsfBa7y2ZcdxHRVEURlEAcX1YDjsGV3xGBnF0RGc0V1HGfGYVbdFDgEvQFwGBGlUPJ5VkKORU/FAQVTAC08Q+O4fES1J0VWVFVWZ2U28X89TT2VERnx/38yMqm/+4vhFqgpJUn9tMOkEJEmTZSGQpJ6zEEhSz1kIJKnnLASS1HMWAknqOQuBJPWchUCSes5CIEk9t2TSCQxjiy22qGXLlk06DUlar5x33nnXV9XUXMutF4Vg2bJlnHvuuZNOQ5LWK0l+MMxy7hqSpJ6zEEhSz1kIJKnnLASS1HMWAknquZEVgiRHJLk2ycVree7AJJVki1G1L0kazih7BEcBO0+fmeT+wE7AD0fYtiRpSCMrBFX1ZeDna3nqMOD1gPfIlKR1wFiPESTZFfhRVV04znYlSTMb25XFSTYB3gQ8fcjlVwArAJYuXTrCzLQueuZnDui03mm7vX+RM5Hu/MbZI3gw8EDgwiRXAtsC5yfZem0LV9XKqlpeVcunpuYcKkOS1NHYegRVdRGw5Zrpthgsr6rrx5WDJOmORnn66MeBrwHbJbk6yX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JtkDeF+a23kuobk37iWL/25IDU8flaSec9eQJPWchUCSes5CIEk9ZyGQpJ6zEEhSz1kIJKnnLASS1HMWAknquf8Pi0XDHPzru+kAAAAASUVORK5CYII=\n", | |
"text/plain": [ | |
"<Figure size 432x288 with 1 Axes>" | |
] | |
}, | |
"metadata": { | |
"needs_background": "light" | |
}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"dataframe = test_score_distribution.DataFrame()\n", | |
"\n", | |
"%matplotlib inline\n", | |
"# uncomment the following line if you get an module error saying seaborn not found\n", | |
"# !pip install seaborn\n", | |
"import seaborn\n", | |
"\n", | |
"plot = seaborn.barplot(x='Test Score',y='Frequency', data=dataframe)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 19, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"#%%sql \n", | |
"\n", | |
"#-- Feel free to experiment with the data set provided in this notebook for practice:\n", | |
"#SELECT country, first_name, last_name, test_score FROM INTERNATIONAL_STUDENT_TEST_SCORES; " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.8" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment