20 lines
433 B
Python
20 lines
433 B
Python
from app import db
|
|
from pandas import DataFrame, read_sql
|
|
|
|
|
|
def create_dataframe(query) -> DataFrame:
|
|
df = read_sql(sql=query, con=db.engine)
|
|
return df
|
|
|
|
|
|
def render_table(df) -> str:
|
|
df.fillna(value=0, inplace=True)
|
|
table = df.to_html(classes=["table-striped", "table-hover"])
|
|
return table
|
|
|
|
|
|
def create_table(query) -> str:
|
|
df = create_dataframe(query)
|
|
html_table = render_table(df)
|
|
return html_table
|