I am new to Python and struggling with maybe a simple issue:
I have a main script called A_script.py. In it is the following code (simplified and anonymised):
if __name__ == '__main__':
import pandas as pd
df_A = pd.read_sql_query('SELECT * FROM [xxx].[xx].[xxxxx]', conn)
A_len = len(df_A.index)
#import script B_script.py
import B_script
B_script contains the following code:
from A_script import df_A
from A_script import A_len
This code in B_script errors when I run the script A_script, as it cannot bring in the variable and the dataframe. How do I get around this, without having to rerun the entire A_script from within B_script that creates df_A and A_len, which is significantly larger and more complex than the example?