kaecvtionr
kaecvtionr

Reputation: 153

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.

Upvotes: 6

Views: 16867

Answers (1)

Maxwell77
Maxwell77

Reputation: 939

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)

Upvotes: 8

Related Questions