You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: redshift_connector/__init__.py
+82Lines changed: 82 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -121,7 +121,85 @@ def connect(
121
121
role_session_name: typing.Optional[str] =None,
122
122
role_arn: typing.Optional[str] =None,
123
123
) ->Connection:
124
+
"""
125
+
Establishes a :class:`Connection` to an Amazon Redshift cluster. This function validates user input, optionally authenticates using an identity provider plugin, then constructs a :class:`Connection` object.
124
126
127
+
Parameters
128
+
----------
129
+
user : str
130
+
The username to use for authentication with the Amazon Redshift cluster.
131
+
password : str
132
+
The password to use for authentication with the Amazon Redshift cluster.
133
+
database : str
134
+
The name of the database instance to connect to.
135
+
host : str
136
+
The hostname of the Amazon Redshift cluster.
137
+
port : int
138
+
The port number of the Amazon Redshift cluster. Default value is 5439.
139
+
source_address : typing.Optional[str]
140
+
unix_sock : Optional[str]
141
+
ssl : bool
142
+
Is SSL enabled. Default value is ``True``. SSL must be enabled when authenticating using IAM.
143
+
sslmode : str
144
+
The security of the connection to the Amazon Redshift cluster. 'verify-ca' and 'verify-full' are supported.
145
+
timeout : Optional[int]
146
+
The number of seconds before the connection to the server will timeout. By default there is no timeout.
147
+
max_prepared_statements : int
148
+
tcp_keepalive : Optional[bool]
149
+
Is `TCP keepalive <https://en.wikipedia.org/wiki/Keepalive#TCP_keepalive>`_ used. The default value is ``True``.
150
+
application_name : Optional[str]
151
+
Sets the application name. The default value is None.
152
+
replication : Optional[str]
153
+
Used to run in `streaming replication mode <https://www.postgresql.org/docs/12/protocol-replication.html>`_.
154
+
idp_host : Optional[str]
155
+
The hostname of the IdP.
156
+
db_user : str
157
+
The user ID to use with Amazon Redshift
158
+
app_id : Optional[str]
159
+
app_name : str
160
+
The name of the identity provider (IdP) application used for authentication.
161
+
preferred_role : str
162
+
The IAM role preferred for the current connection.
163
+
principal_arn : Optional[str]
164
+
credentials_provider : str
165
+
The class name of the IdP that will be used for authenticating with the Amazon Redshift cluster.
166
+
region : str
167
+
The AWS region where the Amazon Redshift cluster is located.
168
+
cluster_identifier : str
169
+
The cluster identifier of the Amazon Redshift cluster.
170
+
iam : bool
171
+
If IAM authentication is enabled. Default value is False. IAM must be True when authenticating using an IdP.
172
+
client_id : str
173
+
The client id from Azure IdP.
174
+
idp_tenant : str
175
+
The IdP tenant.
176
+
client_secret : str
177
+
The client secret from Azure IdP.
178
+
partner_sp_id : Optional[str]
179
+
idp_response_timeout : int
180
+
The timeout for retrieving SAML assertion from IdP. Default value is `120`.
181
+
listen_port : int
182
+
The listen port the IdP will send the SAML assertion to. Default value is `7890`.
183
+
login_url : str
184
+
The SSO url for the IdP.
185
+
auto_create :bool
186
+
Indicates whether the user should be created if they do not exist. Default value is `False`.
187
+
db_groups : str
188
+
A comma-separated list of existing database group names that the `db_user` joins for the current session.
189
+
force_lowercase :
190
+
allow_db_user_override : bool
191
+
Specifies if the driver uses the `db_user` value from the SAML assertion. TDefault value is `False`.
192
+
client_protocol_version : int
193
+
The requested server protocol version. The default value is 1 representing `EXTENDED_RESULT_METADATA`. If the requested server protocol cannot be satisfied, a warning will be displayed to the user.
194
+
database_metadata_current_db_only : bool
195
+
Is `datashare <https://docs.aws.amazon.com/redshift/latest/dg/datashare-overview.html>`_ disabled. Default value is True, implying datasharing will not be used.
196
+
ssl_insecure : bool
197
+
Specifies if IdP host's server certificate will be verified. Default value is True
198
+
199
+
Returns
200
+
-------
201
+
A Connection object associated with the specified Amazon Redshift cluster: :class:`Connection`
202
+
"""
125
203
info: RedshiftProperty=RedshiftProperty()
126
204
IamHelper.set_iam_properties(
127
205
info,
@@ -209,6 +287,9 @@ def connect(
209
287
"""
210
288
211
289
paramstyle: str="format"
290
+
"""
291
+
String property stating the type of parameter marker formatting expected by the interface; This value defaults to "format", in which parameters are marked in this format "WHERE name=%s"
292
+
"""
212
293
213
294
# I have no idea what this would be used for by a client app. Should it be
214
295
# TEXT, VARCHAR, CHAR? It will only compare against row_description's
Creates a :class:`Connection` to an Amazon Redshift cluster. For more information on establishing a connection to an Amazon Redshift cluster using `federated API access <https://aws.amazon.com/blogs/big-data/federated-api-access-to-amazon-redshift-using-an-amazon-redshift-connector-for-python/>`_ see our examples page.
371
+
This is the underlying :class:`Connection` constructor called from :func:`redshift_connector.connect`.
372
+
373
+
Parameters
374
+
----------
375
+
user : str
376
+
The username to use for authentication with the Amazon Redshift cluster.
377
+
password : str
378
+
The password to use for authentication with the Amazon Redshift cluster.
379
+
database : str
380
+
The name of the database instance to connect to.
381
+
host : str
382
+
The hostname of the Amazon Redshift cluster.
383
+
port : int
384
+
The port number of the Amazon Redshift cluster. Default value is 5439.
385
+
source_address : Optional[str]
386
+
unix_sock : Optional[str]
387
+
ssl : bool
388
+
Is SSL enabled. Default value is ``True``. SSL must be enabled when authenticating using IAM.
389
+
sslmode : str
390
+
The security of the connection to the Amazon Redshift cluster. 'verify-ca' and 'verify-full' are supported.
391
+
timeout : Optional[int]
392
+
The number of seconds before the connection to the server will timeout. By default there is no timeout.
393
+
max_prepared_statements : int
394
+
tcp_keepalive : Optional[bool]
395
+
Is `TCP keepalive <https://en.wikipedia.org/wiki/Keepalive#TCP_keepalive>`_ used. The default value is ``True``.
396
+
application_name : Optional[str]
397
+
Sets the application name. The default value is None.
398
+
replication : Optional[str]
399
+
Used to run in `streaming replication mode <https://www.postgresql.org/docs/12/protocol-replication.html>`_.
400
+
client_protocol_version : int
401
+
The requested server protocol version. The default value is 1 representing `EXTENDED_RESULT_METADATA`. If the requested server protocol cannot be satisfied, a warning will be displayed to the user.
402
+
database_metadata_current_db_only : bool
403
+
Is `datashare <https://docs.aws.amazon.com/redshift/latest/dg/datashare-overview.html>`_ disabled. Default value is True, implying datasharing will not be used.
Executes a database operation. Parameters may be provided as a sequence, or as a mapping, depending upon the value of `redshift_connector.paramstyle`.
971
+
972
+
Parameters
973
+
----------
974
+
cursor : :class:`Cursor`
975
+
operation : str The SQL statement to execute.
976
+
vals : If `redshift_connector.paramstyle` is `qmark`, `numeric`, or `format` this argument should be an array of parameters to bind into the statement. If `redshift_connector.paramstyle` is `named` the argument should be a `dict` mapping of parameters. If `redshift_connector.paramstyle` is `pyformat`, the argument value may be either an array or mapping.
0 commit comments