@@ -188,6 +188,9 @@ Alternatively, IAM credentials can be supplied directly to ``connect(...)`` usin
188
188
189
189
Integration with pandas
190
190
~~~~~~~~~~~~~~~~~~~~~~~
191
+
192
+ Retrieving query results as a ``pandas.DataFrame ``
193
+
191
194
.. code-block :: python
192
195
193
196
import pandas
@@ -206,6 +209,28 @@ Integration with pandas
206
209
>> 1 A Brief History of Time Stephen Hawking
207
210
208
211
212
+ Insert data stored in a ``pandas.DataFrame `` into an Amazon Redshift table
213
+
214
+ .. code-block :: python
215
+
216
+ import numpy as np
217
+ import pandas as pd
218
+
219
+ df = pd.DataFrame(
220
+ np.array(
221
+ [
222
+ [" One Hundred Years of Solitude" , " Gabriel García Márquez" ],
223
+ [" A Brief History of Time" , " Stephen Hawking" ],
224
+ ]
225
+ ),
226
+ columns = [" bookname" , " author" ],
227
+ )
228
+ with db_table.cursor() as cursor:
229
+ cursor.write_dataframe(df, " book" )
230
+ cursor.execute(" select * from book; " )
231
+ result = cursor.fetchall()
232
+
233
+
209
234
Integration with numpy
210
235
~~~~~~~~~~~~~~~~~~~~~~
211
236
@@ -275,10 +300,14 @@ Connection Parameters
275
300
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------+
276
301
| max_prepared_statements | int | The maximum number of prepared statements that can be open at once | 1000 | No |
277
302
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------+
303
+ | partner_sp_id | str | The Partner SP Id used for authentication with Ping | None | No |
304
+ +-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------+
278
305
| port | Int | The port number of the Amazon Redshift cluster | 5439 | No |
279
306
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------+
280
307
| preferred_role | str | The IAM role preferred for the current connection | None | No |
281
308
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------+
309
+ | principal_arn | str | The ARN of the IAM entity (user or role) for which you are generating a policy | None | No |
310
+ +-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------+
282
311
| profile | str | The name of a profile in a AWS credentials file that contains AWS credentials. | None | No |
283
312
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------+
284
313
| region | str | The AWS region where the cluster is located | None | No |
0 commit comments