I have set up a flask application and use data downloaded from a mysql db as pandas dataframe. The df ist create by a function and not by a class. There I created a POST Call to reload data which is used for the algorithms.
I want to know how I can rerun the import of df_leitdaten. If I add del df_leitdaten and import again. I do not get the result I wished.
Initialy I import a module which extracts and combine data from the db via
from address_validation_api.etl.db_call import df_leitdaten
In the Script I am doing:
df_a= pd.read_sql(""" SELECT * FROM tab_a""",  open_connection_mysql())
df_b= pd.read_sql(""" SELECT * FROM tab_b""",  open_connection_mysql())
df_c= pd.read_sql(""" SELECT * FROM tab_c""",  open_connection_mysql())
df_d = df_a.append([df_b, df_c])
df_leitdaten = df_d.drop_duplicates(subset=['x', 'y', 'z']
                             keep = 'last')
The POST call exceutes reload_leitdata() and has the functionality:
def initial_leitdata():
    return (df_leitdaten.shape, 
            hashlib.sha256(pd.util.hash_pandas_object(df_leitdaten,
 index=True).values).hexdigest())    
def reload_leitdata():
    before = initial_leitdata()
    LOG.info('Shape of df_before: %s', str(before[0]))
    LOG.info('Hash of df_before: %s', str(before[1]))
    del df_leitdaten
    from address_validation_api.etl.db_call import df_leitdaten
    after = (df_leitdaten.shape,
             hashlib.sha256(pd.util.hash_pandas_object(df_leitdaten,
             index=True).values).hexdigest())
    LOG.info('Shape of df_after: %s', str(after[0]))
    LOG.info('Hash of df_after: %s', str(after[1]))
    status = False
    if not before[1] == after[1]:
        status = True
    return (before, after, status)
I want to show the difference in the shape of the df. I added some data to the db and run the script but the shape of the df does not change. Even if I deployed the API there is no change. My desiered output is something like
{'status':True,
 'Shape of df_before:', (100,2)
 'Hash of df_before:', 'abc',
 'Shape of df_after:', (101,2)
 'Hash of df_after:', 'abcd'}
