how to print contents of table in sqlalchemy

Solutions on MaxInterview for how to print contents of table in sqlalchemy by the best coders in the world

showing results for - "how to print contents of table in sqlalchemy"
Alden
19 Jan 2020
1# create an engine using the following code and 
2# replace it with path to your .db file.
3from sqlalchemy import create_engine
4engine = create_engine('sqlite:///employee.db', echo = False)
5
6# Import pandas and connect the engine
7# use the lowercase representation of your table name
8# For ex:
9class Users(db.Model):
10	...
11    ...
12    ...
13
14import pandas as pd
15
16user_table = pd.read_sql_table(table_name="user", con=engine)
17# This will load the table as dataframe and then you can display