{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "editable": true }, "outputs": [], "source": [ "%load_ext sql" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "editable": true }, "outputs": [ { "data": { "text/plain": [ "'Connected: student@sparkifydb'" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%sql postgresql://student:student@127.0.0.1/sparkifydb" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " * postgresql://student:***@127.0.0.1/sparkifydb\n", "5 rows affected.\n" ] }, { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
songplay_idstart_timeuser_idlevelsong_idartist_idsession_idlocationuser_agent
02018-11-30 12:22:0791freeNoneNone829Dallas-Fort Worth-Arlington, TXMozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)
12018-11-30 01:08:4173paidNoneNone1049Tampa-St. Petersburg-Clearwater, FL"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.78.2 (KHTML, like Gecko) Version/7.0.6 Safari/537.78.2"
22018-11-30 01:12:4873paidNoneNone1049Tampa-St. Petersburg-Clearwater, FL"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.78.2 (KHTML, like Gecko) Version/7.0.6 Safari/537.78.2"
32018-11-30 01:17:0573paidNoneNone1049Tampa-St. Petersburg-Clearwater, FL"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.78.2 (KHTML, like Gecko) Version/7.0.6 Safari/537.78.2"
42018-11-30 01:20:5673paidNoneNone1049Tampa-St. Petersburg-Clearwater, FL"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.78.2 (KHTML, like Gecko) Version/7.0.6 Safari/537.78.2"
" ], "text/plain": [ "[(0, datetime.datetime(2018, 11, 30, 12, 22, 7), 91, 'free', 'None', 'None', 829, 'Dallas-Fort Worth-Arlington, TX', 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)'),\n", " (1, datetime.datetime(2018, 11, 30, 1, 8, 41), 73, 'paid', 'None', 'None', 1049, 'Tampa-St. Petersburg-Clearwater, FL', '\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.78.2 (KHTML, like Gecko) Version/7.0.6 Safari/537.78.2\"'),\n", " (2, datetime.datetime(2018, 11, 30, 1, 12, 48), 73, 'paid', 'None', 'None', 1049, 'Tampa-St. Petersburg-Clearwater, FL', '\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.78.2 (KHTML, like Gecko) Version/7.0.6 Safari/537.78.2\"'),\n", " (3, datetime.datetime(2018, 11, 30, 1, 17, 5), 73, 'paid', 'None', 'None', 1049, 'Tampa-St. Petersburg-Clearwater, FL', '\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.78.2 (KHTML, like Gecko) Version/7.0.6 Safari/537.78.2\"'),\n", " (4, datetime.datetime(2018, 11, 30, 1, 20, 56), 73, 'paid', 'None', 'None', 1049, 'Tampa-St. Petersburg-Clearwater, FL', '\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.78.2 (KHTML, like Gecko) Version/7.0.6 Safari/537.78.2\"')]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%sql SELECT * FROM songplays LIMIT 5;" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " * postgresql://student:***@127.0.0.1/sparkifydb\n", "1 rows affected.\n" ] }, { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", "
count
532
" ], "text/plain": [ "[(532,)]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%sql SELECT count(*) FROM songplays" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " * postgresql://student:***@127.0.0.1/sparkifydb\n", "5 rows affected.\n" ] }, { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
user_idfirst_namelast_namegenderlevel
92RyannSmithFfree
57KatherineGayFfree
86AidenHessMfree
74BradenParkerMfree
30AveryWatkinsFpaid
" ], "text/plain": [ "[(92, 'Ryann', 'Smith', 'F', 'free'),\n", " (57, 'Katherine', 'Gay', 'F', 'free'),\n", " (86, 'Aiden', 'Hess', 'M', 'free'),\n", " (74, 'Braden', 'Parker', 'M', 'free'),\n", " (30, 'Avery', 'Watkins', 'F', 'paid')]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%sql SELECT * FROM users LIMIT 5;" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " * postgresql://student:***@127.0.0.1/sparkifydb\n", "1 rows affected.\n" ] }, { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", "
count
96
" ], "text/plain": [ "[(96,)]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%sql SELECT count(*) FROM users" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " * postgresql://student:***@127.0.0.1/sparkifydb\n", "5 rows affected.\n" ] }, { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
song_idtitleartist_idyearduration
SOMZWCG12A8C13C480I Didn't Mean ToARD7TVE1187B99BFB10218.93179
SOUDSGM12AC9618304Insatiable (Instrumental Version)ARNTLGG11E2835DDB90266.39628
SOIAZJW12AB01853F1Pink WorldAR8ZCNI1187B9A069B1984269.81832
SOHKNRJ12A6701D1F8Drop of RainAR10USD1187B99F3F10189.57016
SOCIWDW12A8C13D406Soul DeepARMJAGH1187FB546F31969148.03546
" ], "text/plain": [ "[('SOMZWCG12A8C13C480', \"I Didn't Mean To\", 'ARD7TVE1187B99BFB1', 0, 218.93179),\n", " ('SOUDSGM12AC9618304', 'Insatiable (Instrumental Version)', 'ARNTLGG11E2835DDB9', 0, 266.39628),\n", " ('SOIAZJW12AB01853F1', 'Pink World', 'AR8ZCNI1187B9A069B', 1984, 269.81832),\n", " ('SOHKNRJ12A6701D1F8', 'Drop of Rain', 'AR10USD1187B99F3F1', 0, 189.57016),\n", " ('SOCIWDW12A8C13D406', 'Soul Deep', 'ARMJAGH1187FB546F3', 1969, 148.03546)]" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%sql SELECT * FROM songs LIMIT 5;" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " * postgresql://student:***@127.0.0.1/sparkifydb\n", "1 rows affected.\n" ] }, { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", "
count
71
" ], "text/plain": [ "[(71,)]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%sql SELECT count(*) FROM songs" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " * postgresql://student:***@127.0.0.1/sparkifydb\n", "5 rows affected.\n" ] }, { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
artist_idnamelocationlatitudelongitude
AR8ZCNI1187B9A069BPlanet P ProjectNoneNone
AR10USD1187B99F3F1Tweeterfriendly MusicBurlington, Ontario, CanadaNoneNone
ARMJAGH1187FB546F3The Box TopsMemphis, TN35.14968-90.04892
ARKFYS91187B98E58FJeff And Sheri EasterNoneNone
ARD0S291187B9B7BF5Rated ROhioNoneNone
" ], "text/plain": [ "[('AR8ZCNI1187B9A069B', 'Planet P Project', '', None, None),\n", " ('AR10USD1187B99F3F1', 'Tweeterfriendly Music', 'Burlington, Ontario, Canada', None, None),\n", " ('ARMJAGH1187FB546F3', 'The Box Tops', 'Memphis, TN', 35.14968, -90.04892),\n", " ('ARKFYS91187B98E58F', 'Jeff And Sheri Easter', '', None, None),\n", " ('ARD0S291187B9B7BF5', 'Rated R', 'Ohio', None, None)]" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%sql SELECT * FROM artists LIMIT 5;" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " * postgresql://student:***@127.0.0.1/sparkifydb\n", "1 rows affected.\n" ] }, { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", "
count
69
" ], "text/plain": [ "[(69,)]" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%sql SELECT count(*) FROM artists" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " * postgresql://student:***@127.0.0.1/sparkifydb\n", "5 rows affected.\n" ] }, { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
start_timehourdayweekmonthyearweekday
2018-11-30 00:22:07.796000030481120184
2018-11-30 01:08:41.796000130481120184
2018-11-30 01:12:48.796000130481120184
2018-11-30 01:17:05.796000130481120184
2018-11-30 01:20:56.796000130481120184
" ], "text/plain": [ "[(datetime.datetime(2018, 11, 30, 0, 22, 7, 796000), 0, 30, 48, 11, 2018, 4),\n", " (datetime.datetime(2018, 11, 30, 1, 8, 41, 796000), 1, 30, 48, 11, 2018, 4),\n", " (datetime.datetime(2018, 11, 30, 1, 12, 48, 796000), 1, 30, 48, 11, 2018, 4),\n", " (datetime.datetime(2018, 11, 30, 1, 17, 5, 796000), 1, 30, 48, 11, 2018, 4),\n", " (datetime.datetime(2018, 11, 30, 1, 20, 56, 796000), 1, 30, 48, 11, 2018, 4)]" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%sql SELECT * FROM time LIMIT 5;" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " * postgresql://student:***@127.0.0.1/sparkifydb\n", "1 rows affected.\n" ] }, { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", "
count
6820
" ], "text/plain": [ "[(6820,)]" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%sql SELECT count(*) FROM time" ] } ], "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.3" } }, "nbformat": 4, "nbformat_minor": 4 }