Answers for "running %%sql jupyter notebook"

SQL
2

sql from jupyter notebooks

# import packages
import pandas as pd
import sqlite3 

# connect database and create cursor
conn = sqlite3.connect('data.sqlite')
cur = conn.cursor()

# executing the query
cur.execute("""SELECT * FROM employees LIMIT 5;""")

# creating a dataframe object
df = pd.DataFrame(cur.fetchall())

# find database attributes from cursor.description to use as column names
cur.description

# creating dataframe columns
df.columns = [x[0] for x in cur.description]
df.head()
Posted by: Guest on August-19-2020

Code answers related to "SQL"

Browse Popular Code Answers by Language