Import SQLite to Python


Can you import a table in a SQLite database into a pandas DataFrame in Python? Yes you can. I will use Anaconda Navigator to create a Jupyter Notebook.

import sqlite3
import pandas as pd

# Create your connection to SQLite.
conn = sqlite3.connect('D:\Test\peopleDB.db')

df = pd.read_sql_query("SELECT * FROM friends", conn)
df

In Jupyter Notebook you get the results of the SQL SELECT statement.

Leave a Reply