Add table querying via form
This commit is contained in:
0
code/processing/__init__.py
Normal file
0
code/processing/__init__.py
Normal file
18
code/processing/tabulate.py
Normal file
18
code/processing/tabulate.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from app import db
|
||||
from pandas import DataFrame, read_sql, wide_to_long
|
||||
|
||||
|
||||
def create_dataframe(query) -> DataFrame:
|
||||
df = read_sql(sql=query, con=db.engine)
|
||||
return df
|
||||
|
||||
|
||||
def render_table(df) -> str:
|
||||
table = df.to_html(classes=["table-bordered", "table-striped", "table-hover"])
|
||||
return table
|
||||
|
||||
|
||||
def create_table(query) -> str:
|
||||
df = create_dataframe(query)
|
||||
html_table = render_table(df)
|
||||
return html_table
|
||||
Reference in New Issue
Block a user