Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import a SQLite3 database into Python Jupyter Notebook?

How do you import an SQLite3 database file you have stored on your computer into Python Jupyter Notebook?

My goal is to be able to analyze the data in Python Pandas the same way I do when I import CSV files.

like image 751
kaecvtionr Avatar asked Jun 23 '18 00:06

kaecvtionr


Video Answer


1 Answers

import sqlite3
import pandas as pd

# Create the connection
cnx = sqlite3.connect(r'C:\mydatabases\bigdata.db')

# create the dataframe from a query
df = pd.read_sql_query("SELECT * FROM userdata", cnx)
like image 103
Maxwell77 Avatar answered Oct 28 '22 11:10

Maxwell77