Amazon Redshift는 2025년 11월 1일부터 새 Python UDF 생성을 더 이상 지원하지 않습니다. Python UDF를 사용하려면 이 날짜 이전에 UDF를 생성하세요. 기존 Python UDF는 정상적으로 계속 작동합니다. 자세한 내용은 블로그 게시물
NumPy와 Python 커넥터 통합
다음은 Python 커넥터를 NumPy와 통합하는 예입니다.
>>> import numpy #Connect to the cluster >>> import redshift_connector >>> conn = redshift_connector.connect( host='examplecluster.abc123xyz789.us-west-1.redshift.amazonaws.com', port=5439, database='dev', user='awsuser', password='my_password' ) # Create a Cursor object >>> cursor = conn.cursor() # Query and receive result set cursor.execute("select * from book") result: numpy.ndarray = cursor.fetch_numpy_array() print(result)
다음은 결과입니다.
[['One Hundred Years of Solitude' 'Gabriel García Márquez'] ['A Brief History of Time' 'Stephen Hawking']]