import sqlalchemy as db
import pandas as pd
engine = db.create_engine('sqlite:///traffic.sqlite') # just for example
# AFTER those 3 lines, there are several ways
# one way to do it by using context manager
with engine.connect() as con:
dbqu=con.execute("SELECT * FROM employee")
df=pd.DataFrame(dbqu.fetchall())
# another alternate way is pretty simple by using pandas
df= pd.read_sql_query("SELECT * FROM employee", engine)
# the last tedious way--
con=engine.connect()
dbqu=con.execute("SELECT * FROM employee")
df=pd.DataFrame(dbqu.fetchall())
con.close() # WARNING- don't forget to close the connection in this last format