Articles → PANDAS → Read_Sql Function In Pandas

Read_Sql Function In Pandas






Purpose





Installing Sqlalchemy




pip install sqlalchemy



Example






import pandas as pd
from sqlalchemy import create_engine


engine = create_engine("sqlite:///c:\sqlite\SchoolDB.db")
engine.connect()


df = pd.DataFrame()
df = pd.read_sql('select * from Departments', con=engine)
print(df)



Output


Picture showing the output of read_sql function in pandas
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Tuesday, June 4, 2019

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250