filmov
tv
Run SQL in Jupyter Notebooks - Python Recipes
Показать описание
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
################################
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
################################
Комментарии