Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Integrating the Python connector with NumPy - Amazon Redshift

Integrating the Python connector with NumPy

Following is an example of integrating the Python connector with 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)

Following is the result.

[['One Hundred Years of Solitude' 'Gabriel García Márquez'] ['A Brief History of Time' 'Stephen Hawking']]
PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.