SQLite query with pandas in Python

SQLite queries in Python can be implemented with sqlite3 and pandas. The advantage of using pandas for query execution is that the return value is a pandas DataFrame. Handling a pandas DataFrame might be handy.

Below result implements and executes a simple SELECT query in Pythin using pandas and sqlite3.

import pandas as pd
import sqlite3

# connect to database
con = sqlite3.connect('sales.db')

# write query
query = '''
SELECT *
FROM clients
'''

# execute query in Python using pandas (obtaining results in DataFrame format)
df = pd.read_sql_query(query, conn)