Answers for "how to print contents of table in sqlalchemy"

0

how to print contents of table in sqlalchemy

# create an engine using the following code and 
# replace it with path to your .db file.
from sqlalchemy import create_engine
engine = create_engine('sqlite:///employee.db', echo = False)

# Import pandas and connect the engine
# use the lowercase representation of your table name
# For ex:
class Users(db.Model):
	...
    ...
    ...

import pandas as pd

user_table = pd.read_sql_table(table_name="user", con=engine)
# This will load the table as dataframe and then you can display
Posted by: Guest on May-22-2021

Code answers related to "how to print contents of table in sqlalchemy"

Python Answers by Framework

Browse Popular Code Answers by Language