Created
October 9, 2016 15:50
-
-
Save alejio/8771c8da2f6d873d8d690c9a82354b89 to your computer and use it in GitHub Desktop.
how to read from a sqlite db
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from sqlalchemy import create_engine # database connection | |
import datetime as dt | |
from IPython.display import display | |
import matplotlib | |
import numpy as np | |
import matplotlib.pyplot as plt | |
pd.set_option('display.max_columns', 120) | |
%matplotlib inline | |
# Read SQL engine from created db | |
disk_engine = create_engine('sqlite:///history.db') | |
# Execute SQL query and save to pandas dataframe | |
df_base = pd.read_sql_query('SELECT ' + ", ".join(cols_to_import) + ' FROM data', disk_engine) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment