Run SQL in Jupyter Notebooks - Python Recipes

preview_player
Показать описание
Learn how to use Jupyter Notebooks to read and right data from Databases with SQL.

The procedures shown on this video work with any database that has a python API and can serve as a quick and practical way to retrieve and/or report data for analysis.

#jupiter #jupyter #sql #python

Table of Contents:

00:32 - Why would I use SQL in Jupyter Notebooks?
01:00 - Subscribe and Like
01:25 - Importing rquired libraries
01:55 - Install iPython-sql library
02:10 - Creating Demo Data
03:27 - Connect to the db and run SQL

SUBSCRIBE TO OUR YOUTUBE CHANNEL

################################
CODE
################################

# import libraries
import pandas as pd
import sqlite3

# install the ipython-sql libray
!pip install ipython-sql

# create a dataframe to import data for the tutorial
df= pd.DataFrame({'name': ['Juan', 'Victoria', 'Mary'],
'age': [23,34,43],
'city': ['Miami', 'Buenos Aires','Santiago']})

df

# We will sqlite3 library and create a connection

%load_ext sql

%%sql
SELECT *
FROM people

%%sql
SELECT count(*)
FROM people

%%sql
SELECT sum(age) as 'age_sum'
FROM people

################################
/ CODE
################################
Рекомендации по теме
Комментарии
Автор

Very straightforward and works on my end. Thank you!

denisepatrick
Автор

Thank you so much for a short, yet very useful information.

SriRam-yqid
Автор

THANK YOU SO MUCH! Short, straight forward, easy to understand. Helped me a lot

bragedybwad
Автор

Thank you so much for your video, I was have problem using sql in my jupyter notebook and many tutorial I had follow and it result always error or anything else. but with your video I can do it now. thank you

mulhaswansaputra
Автор

Thank you so much. It was really helpful.

nabanitadasgupta
Автор

Thanks for sharing. It was very helpful

sahanav
Автор

Fabulous! Thanks a bunch. You are awesome!

RyanLBuchanan
Автор

Perfect ! you helped me a lot with this nice video :D

fabiogustavo
Автор

Awesome video, really good. Thank you so much.

pulokchakraborty
Автор

Great video! Could you please make another video explaining how to connect to a file saved in a given directory and to a file in github? Thank you

patite
Автор

Thanks. Didn't know we can do stuff like that.

ssgoh
Автор

thank u so much it help me more, our profit Mohamed teach us He who does not thank people does not thank God

seesczm
Автор

very nice Explanation I have a doubt i loaded a csv file into table into sqlite3 using pd.read_csv. when i access that table from sqlite3 to pandas df using pd.read_sql_table() it is showing NotImplementedError kindly help to reslove this.

zlhohpo
Автор

I keep getting 'The SQL module is not an ipython extension' when I run the %load_ext sql command. As for the database, I'm using postgreSQL. After connecting it I got a UsageError: Line magic function '%sql' not found

zubee
Автор

Well explained, is there a way to connect to postgresql as well ?

nth.education
Автор

Thank you. How create a dataframe from the output of the select table?

bharatbhanushali
Автор

Thank you for the video! Would it be possible to do a video showing the adaptation to Jupyterlab? Thank you!

patite
Автор

how to run sql query for 2 tables with this code?

anushkamote
Автор

Is it possible to read .sql file in jupyter notebook ?

rabhishekshetty
Автор

I have MySQL workbench installed on my machine. How do i connect it to jupyter notebook? Thanks

jamesleleji