Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_last_change(table: str, executor=None) -> pd.DataFrame(): #TODO add condition to check if table_audit exist
- if executor is None:
- executor: Executor = st.session_state['executor']
- # query = f"SELECT * FROM _defaults._global_audit ORDER BY STAMP DESC LIMIT 5"
- query_test = f"""SELECT EXISTS (
- SELECT FROM
- pg_tables
- WHERE
- schemaname = '{schema}' AND
- tablename = '{table}_audit'
- );"""
- if executor.execute(query_test)[0][0] == True:
- sql = SqlCreatorAlpha(table=f'{table}_audit', schema=schema)
- sql.select().order_by('STAMP', how='DESC').limit(5)
- # df = pd.read_sql(query, conn)
- df = executor.execute(sql).as_dataframe
- return df
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement