import  cx_Oracle  
import  pandas  as  pd  
dsn = cx_Oracle.makedsn( 'localhost' , 1521, 'xe')   
db = cx_Oracle.connect('c##scott','tiger', dsn)  
cursor  = db.cursor()       
#나의 오라클 디비에 있는 테이블명 리스트를 CURSOR라는 메모리에 올린것이다! 
cursor.execute(""" select  table_name 
                     from  dba_tables 
                     where  owner  in  ('C##SCOTT', 'HR', 'SH', 'OE')  
                     and  table_name  not like 'DR%' 
                    """)   
#커서에 있는 데이터를 불러와서 row변수에 담아냄. 
row = cursor.fetchall()    
table_list = [] 
for i in row: 
    table_list.append(i[0]) 
table_list.sort() 
for table_name in table_list: 
    df = table_def(table_name) 
     
    # output_path = f"c:\\aaa2\\{table_name}_df.xlsx" 
    # df.to_excel(output_path)  
    df.to_excel(f"C:\\aaa2\\{table_name}.xlsx")     
     
print("Excel 파일 생성이 완료되었습니다.")