Basically my code looks like this surrounded by some logging:
df_name.to_sql('df_name', engine, index=False)
What I would like to do is to wrap it into a function and use df_name
twice:
def df_2_sql(df):
df.to_sql(f'{df}', engine, index=False)
df_list = [df_table_a, df_table_b, df_table_c]
for df in df_list:
df_2_sql(df)
...I've expected f'{df}'
to work, but it sadly doesn't. I want to use df_list as as pandas objects as well as part of the table name in the to_sql()
function.
I've already tried to use two lists
df_list = [df_table_a, df_table_b, df_table_c]
df_list = ['df_table_a', 'df_table_b', 'df_table_c']
..and a function which expects two arguments, but it doesn't feel right or smart. What am I doing wrong?