Connections
Redshift와 연결을 해주는 객체 connection 생성시 접속 정보 등이 코드 상에 노출되는 이슈가 있는데 이를 해결하기 위해서 airflow connections를 사용할 수 있습니다. 환경설정 형태로 코드 밖으로 꺼내줍니다.
🔽 관련 글 보기 connection 객체
Python 라이브러리 psycopg2로 PostgreSQL 데이터베이스 연결
psycopg2란?PostgreSQL 전용 Python과 연결을 지원하는 라이브러리다중 스레드와 대량 데이터 처리 지원 psycopg2 주요 기능트랜잭션 관리 commit(), rollback()SQL 실행 execute(), executemany()를 사용해 쿼리 실행
ourjune.tistory.com
Variables
pythonOperator 함수의 인자로 전달해서 param으로 처리했는데 variables를 사용하면 airflow를 key-value 스토리지 형태로 사용
환경설정 형태로 코드 밖으로 꺼내줍니다.
Web UI에서 Variables와 Connections 설정
Airflow 웹UI에서 Admin 메뉴에서 Variables와 Connections 설정 가능
variables와 connections 초기 페이지는 기존에 설정해둔 값들이 리스트업되고
하단의 + 버튼을 통해서 생성/추가할 수 있다.
Add Connections
- Connections Id
- Connection Type
- Description
- Schema
- AWS Access Key ID
- AWS Secret Access Key
- Extra
Add Variables
- Key
- Val
- Description
터미널에서 확인
- (airflow)airflow variables list
- (airflow)airflow variables [variables 키]
- (airflow)airflow connections list
'데브코스 데이터엔지니어링' 카테고리의 다른 글
[Airflow] PostgreSQL 데이터를 Redshift로 적재하는 Airflow DAG 코드 (2) | 2024.12.28 |
---|---|
[Airflow] Airflow Xcom (0) | 2024.12.28 |
[SQL] 테이블 레코드 삭제 delete from vs. truncate 차이 (0) | 2024.12.28 |
[Airflow] Full Refresh ETL 작성시 고려사항 (0) | 2024.12.28 |
Python 라이브러리 psycopg2로 PostgreSQL 데이터베이스 연결 (1) | 2024.12.28 |