수업정리/Fundamental

[Python] 한글 유니코드 12 - 기말

GreenBNN 2023. 6. 16. 13:13

sqlite3 을 연결해서 쿼리를 실행하고 그 결과를 .txt 파일로 저장하는 방법

 

https://greenbnn98.tistory.com/88

run_sql.sh : 커멘드에서 쿼리를 실행해 결과를 얻을 수 있다

han_sqldb.py 에서 쿼리를 실행해 결과를 얻을 수 있다  

test_sqldb.py : sqlite3 딥비를 연결하고 원하는 쿼리문 실행하는 함수로 결과 뽑아내기


https://greenbnn98.tistory.com/89

엑셀 파일을 다운로드 해서 데이터를 읽기

구글 드라이브에서 파일을 읽어오기

pandas_xlsx_func.py   : 판다를 이용해 엑셀 파일 데이터를 읽는 함수 작성


https://greenbnn98.tistory.com/90

music_pandas_xls2sql.py : 판다를 이용해 엑셀 테이터를 sqldb 로 전달하기

sheet 가 여러개일 때

sh_names = Efile.sheet_names    :  sheet 이름 가져오기

df = pd.read_excel(Efile, sh_name)   :  엑셀 한 sheet 를 읽고

df.to_sql(tablename, conn)    :   읽은 데이터를 sql 에 넣기


https://greenbnn98.tistory.com/91?category=1145046 

 

db 를 연결해서 select, union, group by, order by 같은 쿼리 문을 실행시켜 결과 출력하

find_musicdb.py