Skip to content Skip to sidebar Skip to footer

Exporting Sql Query Results To Pandas Dataframe

id date temp prcp 1 2015-01-01 -27.18 0 1 2015-01-02 -25.9 1.03 1 2015-01-03 -17.89 9.44 1 2015-01-04 -17.89 9.44 1 2015-01-05 -1

Solution 1:

You could do something like this:

   import sqlite3
   import pandas as pd
   con = sqlite3.connect('path_to_your_sql')
   myFrames = pd.read_sql_query('your query', con)

Edit: for non sqlite db you could use this for the connection:

from sqlalchemy import create_engine
con = create_engine('dialect+driver://username:password@host:port/database')

docs for create_engine


Post a Comment for "Exporting Sql Query Results To Pandas Dataframe"