2020-01-09 19:13:24 +01:00
|
|
|
from app import db
|
2020-01-09 20:56:17 +01:00
|
|
|
from pandas import DataFrame, read_sql
|
2020-01-09 19:13:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
def create_dataframe(query) -> DataFrame:
|
|
|
|
df = read_sql(sql=query, con=db.engine)
|
|
|
|
return df
|
|
|
|
|
|
|
|
|
|
|
|
def render_table(df) -> str:
|
2020-01-09 20:56:17 +01:00
|
|
|
df.fillna(value=0, inplace=True)
|
|
|
|
table = df.to_html(classes=["table-striped", "table-hover"])
|
2020-01-09 19:13:24 +01:00
|
|
|
return table
|
|
|
|
|
|
|
|
|
|
|
|
def create_table(query) -> str:
|
|
|
|
df = create_dataframe(query)
|
|
|
|
html_table = render_table(df)
|
|
|
|
return html_table
|