소연의_개발일지

1. 필요 모듈

<python />
import pandas as pd import matplotlib.pyplot as plt from sqlalchemy import create_engine

 없다면 콘솔창에서 설치하거나 인터프리터 설정에서 추가해 준다.

 

2. 설치 명령어

<python />
''' 설치해야함 pip install sqlalchemy psycopg2 pip install pandas pip install matplotlib '''

 

3. 예시 코드

<python />
import pandas as pd import matplotlib.pyplot as plt from sqlalchemy import create_engine # PostgreSQL과 연결 DATABASE_URL = "postgresql+psycopg2://postgres:1234@10.10.20.103:5432/franchise" engine = create_engine(DATABASE_URL) # 쿼리문 sql = 'SELECT * FROM "테이블이름"' df = pd.read_sql(sql, engine) # 출력 print(df)

 

 

4. 적용 코드

<python />
# 모듈 import import pandas as pd import matplotlib.pyplot as plt from sqlalchemy import create_engine # PostgreSQL과 연결 DATABASE_URL = "postgresql+psycopg2://postgres:1234@10.10.20.103:5432/franchise" engine = create_engine(DATABASE_URL) # 쿼리문 sql = 'SELECT * FROM "TB_ACTUAL_PRICE"' df = pd.read_sql(sql, engine) # 출력 print(df)
profile

소연의_개발일지

@ssoyxon

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!