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()

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
oracle jupyter sql notebook using %sql in jupyter read sql in jupyter notebook sql query in jupyter notebook on dataframe sql query in jupyter notebook sql query from terminal jupyter notebook sql query jupyter notebook create sql database jupyter notebook sql commands in jupyter notebook run sql server query in jupyter notebook run sql query in jupyter notebook sql syntax jupyter notebook can we run sql in jupyter notebook view sql jupyter notebook write sql in jupyter notebook sql explorer jupyter notebook jupyter sql sql on jupyter notebook sql in python jupyter notebook can you sql query in jupyter notebook running sql in jupyter notebook doing sql in jupyter notebook SQL queries from a Jupyter Notebook can you use sql in jupyter notebook jupyter notebook sql server sql jupyter notebook how to use sql in jupyter notebook %sql jupyter jupyter notebook database how to load multiple jupyter databases jupyter open .sql how to run sql queries in jupyter notebook %sql jupyter notebook load sql in jupyter write sql and python in the same notebook jupyter connect to DB jupyter notebook pyton library %%sql jupyter notebook pyton library %%%sql run mysql in jupyter lab sql code in jupyter notebook jupytet insert data to sql sql query in python notebook how to run sql query in python notebook using without magic function how to run sql query in python notebook connect to sql jupyter data analysis of database from jupyter how to create a table in sql using jupyter notebook sql in jupyter notebook install sql in jupyter notebook sql jupyter sql file to jupyter notebook simple database sample jupyter notebook integrated database run sql jupyter notebook make database jupyter python executing sql script from jupyter notebook best way to build a data base to a jupyter notebook notebook allow to save as sql file how to select a perticular data set in mysql connected to the juypter note book jupyter notebook connect to sql notebook jupyter mysql how to run sql on jupyter notebook how to run sql in jupyter notebook sql jupyter notebooks sql and jupyter notebook running %%sql jupyter notebook sql string jupyter notebook sql for jupyter import sql database file in jupyter notebook jupyter sql database interactive jupyter notebook for sql Run mysql in jupyter notebook without python Run sql in jupyter notebook without python run sql in jupyter notebook jupyter notebook sql sql from jupyter notebooks
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source