redshift-connector


Nameredshift-connector JSON
Version 2.1.1 PyPI version JSON
download
home_pagehttps://github.com/aws/amazon-redshift-python-driver
SummaryRedshift interface library
upload_time2024-04-15 16:12:18
maintainerNone
docs_urlNone
authorAmazon Web Services
requires_python>=3.6
licenseApache License 2.0
keywords redshift dbapi
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            =======================================================
redshift_connector
=======================================================

|Python Version| |PyPi|

.. |PyPi| image:: https://img.shields.io/pypi/v/redshift_connector.svg?maxAge=432000&style=flat-square
   :target: https://pypi.org/project/redshift_connector/

.. |Python Version| image:: https://img.shields.io/badge/python->=3.6-brightgreen.svg
   :target: https://pypi.org/project/redshift_connector/

``redshift_connector`` is the Amazon Redshift connector for
Python. Easy integration with `pandas <https://github.com/pandas-dev/pandas>`_ and `numpy <https://github.com/numpy/numpy>`_, as well as support for numerous Amazon Redshift specific features help you get the most out of your data

Supported Amazon Redshift features include:

- IAM authentication
- Identity provider (IdP) authentication
- Redshift specific data types


This pure Python connector implements `Python Database API Specification 2.0 <https://www.python.org/dev/peps/pep-0249/>`_.


Getting Started
---------------

Install from Binary
~~~~~~~~~~~~~~~~~~~

+----------------------------------------------------------------+--------------------+-----------------------------------------------------+
| Package Manager                                                | Downloads          | Installation Command                                |
+================================================================+====================+=====================================================+
| `PyPi <https://pypi.org/project/redshift-connector/>`_         |  |PyPi Downloads|  | ``pip install redshift_connector``                  |
+----------------------------------------------------------------+--------------------+-----------------------------------------------------+
| `Conda <https://anaconda.org/conda-forge/redshift_connector>`_ |  |Conda Downloads| | ``conda install -c conda-forge redshift_connector`` |
+----------------------------------------------------------------+--------------------+-----------------------------------------------------+

.. |PyPi Downloads| image:: https://pepy.tech/badge/redshift_connector
.. |Conda Downloads| image:: https://img.shields.io/conda/dn/conda-forge/redshift_connector.svg


Install from Source
~~~~~~~~~~~~~~~~~~~
You may install from source by cloning this repository.

.. code-block:: sh

    $ git clone https://github.com/aws/amazon-redshift-python-driver.git
    $ cd redshift_connector
    $ pip install .

Tutorials
~~~~~~~~~
- `001 - Connecting to Amazon Redshift <https://github.com/aws/amazon-redshift-python-driver/blob/master/tutorials/001%20-%20Connecting%20to%20Amazon%20Redshift.ipynb>`_
- `002 - Data Science Library Integrations <https://github.com/aws/amazon-redshift-python-driver/blob/master/tutorials/002%20-%20Data%20Science%20Library%20Integrations.ipynb>`_
- `003 - Amazon Redshift Feature Support <https://github.com/aws/amazon-redshift-python-driver/blob/master/tutorials/003%20-%20Amazon%20Redshift%20Feature%20Support.ipynb>`_
- `004 - Amazon Redshift Datatypes <https://github.com/aws/amazon-redshift-python-driver/blob/master/tutorials/004%20-%20Amazon%20Redshift%20Datatypes.ipynb>`_

We are working to add more documentation and would love your feedback. Please reach out to the team by `opening an issue <https://github.com/aws/amazon-redshift-python-driver/issues/new/choose>`__ or `starting a discussion <https://github.com/aws/amazon-redshift-python-driver/discussions/new>`_ to help us fill in the gaps in our documentation.

Integrations
~~~~~~~~~~~~
``redshift_connector`` integrates with various open source projects to provide an interface to Amazon Redshift. Please `open an issue <https://github.com/aws/amazon-redshift-python-driver/issues/new/choose>`__ with our project to request new integrations or get support for a ``redshift_connector`` issue seen in an existing integration.

- `apache-airflow <https://github.com/apache/airflow>`_
- `querybook <https://github.com/pinterest/querybook>`_
- `sqlalchemy-redshift <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift>`_

Basic Example
~~~~~~~~~~~~~
.. code-block:: python

    import redshift_connector

    # Connects to Redshift cluster using AWS credentials
    conn = redshift_connector.connect(
        host='examplecluster.abc123xyz789.us-west-1.redshift.amazonaws.com',
        database='dev',
        user='awsuser',
        password='my_password'
     )

    cursor: redshift_connector.Cursor = conn.cursor()
    cursor.execute("create Temp table book(bookname varchar,author varchar)")
    cursor.executemany("insert into book (bookname, author) values (%s, %s)",
                        [
                            ('One Hundred Years of Solitude', 'Gabriel García Márquez'),
                            ('A Brief History of Time', 'Stephen Hawking')
                        ]
                      )
    cursor.execute("select * from book")

    result: tuple = cursor.fetchall()
    print(result)
    >> (['One Hundred Years of Solitude', 'Gabriel García Márquez'], ['A Brief History of Time', 'Stephen Hawking'])

Enabling autocommit
~~~~~~~~~~~~~~~~~~~
**Following the DB-API specification, autocommit is off by default**. It can be turned on by using the autocommit property of the connection.

.. code-block:: py3

    # Make sure we're not in a transaction
    conn.rollback()
    conn.autocommit = True
    conn.run("VACUUM")
    conn.autocommit = False


Configuring paramstyle
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Paramstyle can be set on both a module and cursor level. When paramstyle is set on a module level e.g. ``redshift_connector.paramstyle = 'qmark'``, the user specified paramstyle is used for all subsequent cursors unless set on the cursor.
When paramstyle is set on the cursor e.g. ```cursor.paramstyle = 'qmark'`` the user specified paramstyle is only used for that cursor object.

.. code-block:: python

    # setting paramstyle to qmark on a module level
    redshift_connector.paramstyle = 'qmark'


    with redshift_connector.connect() as conn1:
        with conn1.cursor() as cursor1: # this cursor will use qmark paramstyle as it's been set on the module level
            pass

        with conn1.cursor() as cursor2:
            # setting paramstyle to numeric on the cursor level only this cursor will use numeric paramstyle
            cursor.paramstyle = 'numeric'

        with conn1.cursor() as cursor3: # this cursor will use qmark paramstyle as it's been set on the module level
            pass

     with redshift_connector.connect() as conn2:
        with conn2.cursor() as cursor1: # this cursor will use qmark paramstyle as it's been set on the module level
            pass


The module level default paramstyle used is ``format``. Valid values for ``paramstyle`` include ``qmark, numeric, named, format, pyformat``. The below example shows how to use various paramstyles after the paramstyle is set on the cursor.

When paramstyle is set to ``named`` or ``pyformat``, parameters must be passed as a Python dictionary to the ``execute()`` method. Other paramstyles require parameters to be passed as a Python tuple or list.

.. code-block:: python

    # qmark
    cursor.paramstyle = 'qmark'
    sql = 'insert into foo(bar, jar) VALUES(?, ?)'
    cursor.execute(sql, (1, "hello world"))

    # numeric
    cursor.paramstyle = 'numeric'
    sql = 'insert into foo(bar, jar) VALUES(:1, :2)'
    cursor.execute(sql, (1, "hello world"))

    # named
    cursor.paramstyle = 'named'
    sql = 'insert into foo(bar, jar) VALUES(:p1, :p2)'
    cursor.execute(sql, {"p1":1, "p2":"hello world"})

    # format
    cursor.paramstyle = 'format'
    sql = 'insert into foo(bar, jar) VALUES(%s, %s)'
    cursor.execute(sql, (1, "hello world"))

    # pyformat
    cursor.paramstyle = 'pyformat'
    sql = 'insert into foo(bar, jar) VALUES(%(bar)s, %(jar)s)'
    cursor.execute(sql, {"bar": 1, "jar": "hello world"})


Exception Handling
~~~~~~~~~~~~~~~~~~~
``redshift_connector`` uses the guideline for exception handling specified in the `Python DB-API <https://www.python.org/dev/peps/pep-0249/#exceptions>`_. For exception definitions, please see `redshift_connector/error.py <https://github.com/aws/amazon-redshift-python-driver/blob/master/redshift_connector/error.py>`_

Example using IAM Credentials
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IAM Credentials can be supplied directly to ``connect(...)`` using an AWS profile as shown below:

.. code-block:: python

    import redshift_connector

    # Connects to Redshift cluster using IAM credentials from default profile defined in ~/.aws/credentials
    conn = redshift_connector.connect(
        iam=True,
        database='dev',
        db_user='awsuser',
        password='',
        user='',
        cluster_identifier='examplecluster',
        profile='default'
     )

.. code-block:: bash

    # ~/.aws/credentials
    [default]
    aws_access_key_id="my_aws_access_key_id"
    aws_secret_access_key="my_aws_secret_access_key"
    aws_session_token="my_aws_session_token"

    # ~/.aws/config
    [default]
    region=us-west-2

If a region is not provided in `~/.aws/config` or you would like to override its value, `region` may be passed to ``connect(...)``.

Alternatively, IAM credentials can be supplied directly to ``connect(...)`` using AWS credentials as shown below:

.. code-block:: python

    import redshift_connector

    # Connects to Redshift cluster using IAM credentials from default profile defined in ~/.aws/credentials
    conn = redshift_connector.connect(
        iam=True,
        database='dev',
        db_user='awsuser',
        password='',
        user='',
        cluster_identifier='examplecluster',
        access_key_id="my_aws_access_key_id",
        secret_access_key="my_aws_secret_access_key",
        session_token="my_aws_session_token",
        region="us-east-2"
     )

Integration with pandas
~~~~~~~~~~~~~~~~~~~~~~~

Retrieving query results as a ``pandas.DataFrame``

.. code-block:: python

    import pandas
    cursor.execute("create Temp table book(bookname varchar,author varchar)")
    cursor.executemany("insert into book (bookname, author) values (%s, %s)",
                       [
                           ('One Hundred Years of Solitude', 'Gabriel García Márquez'),
                           ('A Brief History of Time', 'Stephen Hawking')

                       ])
    cursor.execute("select * from book")
    result: pandas.DataFrame = cursor.fetch_dataframe()
    print(result)
    >>                         bookname                 author
    >> 0  One Hundred Years of Solitude  Gabriel García Márquez
    >> 1        A Brief History of Time         Stephen Hawking


Insert data stored in a ``pandas.DataFrame`` into an Amazon Redshift table

.. code-block:: python

    import numpy as np
    import pandas as pd

    df = pd.DataFrame(
        np.array(
            [
                ["One Hundred Years of Solitude", "Gabriel García Márquez"],
                ["A Brief History of Time", "Stephen Hawking"],
            ]
        ),
        columns=["bookname", "author‎"],
    )
    with conn.cursor() as cursor:
        cursor.write_dataframe(df, "book")
        cursor.execute("select * from book; ")
        result = cursor.fetchall()


Integration with numpy
~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: python

    import numpy
    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']]

Query using functions
~~~~~~~~~~~~~~~~~~~~~
.. code-block:: python

    cursor.execute("SELECT CURRENT_TIMESTAMP")
    print(cursor.fetchone())
    >> [datetime.datetime(2020, 10, 26, 23, 3, 54, 756497, tzinfo=datetime.timezone.utc)]


Connection Parameters
~~~~~~~~~~~~~~~~~~~~~
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| Name                              | Type | Description                                                                                                                                                                                                                                                                                                                                                                                               | Default Value          | Required |
+===================================+======+===========================================================================================================================================================================================================================================================================================================================================================================================================+========================+==========+
| access_key_id                     | str  | The access key for the IAM role or IAM user configured for IAM database authentication                                                                                                                                                                                                                                                                                                                    | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| allow_db_user_override            | bool | True specifies the driver uses the DbUser value from the SAML assertion while False indicates the value in the DbUser connection parameter is used                                                                                                                                                                                                                                                        | FALSE                  | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| app_name                          | str  | The name of the IdP application used for authentication                                                                                                                                                                                                                                                                                                                                                   | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| auth_profile                      | str  | The name of an Amazon Redshift Authentication profile having connection properties as JSON. See the RedshiftProperty class to learn how connection parameters should be named.                                                                                                                                                                                                                            | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| auto_create                       | bool | Indicates whether the user should be created if they do not exist                                                                                                                                                                                                                                                                                                                                         | FALSE                  | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| client_id                         | str  | The client id from Azure IdP                                                                                                                                                                                                                                                                                                                                                                              | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| client_secret                     | str  | The client secret from Azure IdP                                                                                                                                                                                                                                                                                                                                                                          | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| cluster_identifier                | str  | The cluster identifier of the Amazon Redshift Cluster                                                                                                                                                                                                                                                                                                                                                     | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| credentials_provider              | str  | The IdP that will be used for authenticating with Amazon Redshift.                                                                                                                                                                                                                                                                                                                                        | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| database                          | str  | The name of the database to connect to                                                                                                                                                                                                                                                                                                                                                                    | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| database_metadata_current_db_only | bool | Indicates if application supports multi-database datashare catalogs. Default value of  True indicates application does not support multi-database datashare catalogs for backwards compatibility                                                                                                                                                                                                          | TRUE                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| db_groups                         | list | A comma-separated list of existing database group names that the DbUser joins for the current session                                                                                                                                                                                                                                                                                                     | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| db_user                           | str  | The user ID to use with Amazon Redshift                                                                                                                                                                                                                                                                                                                                                                   | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| endpoint_url                      | str  | The Amazon Redshift endpoint url. This option is only used by AWS internal teams.                                                                                                                                                                                                                                                                                                                         | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| group_federation                  | bool | Use the IdP Groups in the Redshift. Default value False.                                                                                                                                                                                                                                                                                                                                                  | False                  | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| host                              | str  | The hostname of Amazon Redshift cluster                                                                                                                                                                                                                                                                                                                                                                   | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| iam                               | bool | If IAM Authentication is enabled                                                                                                                                                                                                                                                                                                                                                                          | FALSE                  | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| iam_disable_cache                 | bool | This option specifies whether the IAM credentials are cached. By default the IAM credentials are cached. This improves performance when requests to the API gateway are throttled.                                                                                                                                                                                                                        | FALSE                  | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| identity_namespace                | str  | The identity namespace to be used for the IdC browser auth plugin and IdP token auth plugin. It is an optional value if there is only one IdC instance existing or if default identity namespace is set on the cluster - else it is required.                                                                                                                                                             | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| idp_response_timeout              | int  | The timeout for retrieving SAML assertion from IdP                                                                                                                                                                                                                                                                                                                                                        | 120                    | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| idp_tenant                        | str  | The IdP tenant                                                                                                                                                                                                                                                                                                                                                                                            | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| listen_port                       | int  | The listen port IdP will send the SAML assertion to                                                                                                                                                                                                                                                                                                                                                       | 7890                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| login_to_rp                       | str  | Only for AdfsCredentialsProvider. Used to specify the loginToRp when performing IdpInitiatedSignOn as apart of form based authentication.                                                                                                                                                                                                                                                                 | urn:amazon:webservices | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| login_url                         | str  | The SSO Url for the IdP                                                                                                                                                                                                                                                                                                                                                                                   | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| max_prepared_statements           | int  | The maximum number of prepared statements that can be open at once                                                                                                                                                                                                                                                                                                                                        | 1000                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| numeric_to_float                  | bool | Specifies if NUMERIC datatype values will be converted from decimal.Decimal to float. By default NUMERIC values are received as decimal.Decimal. Enabling this option is not recommended for use cases which prefer the most precision as results may be rounded. Please reference the Python docs on decimal.Decimal to see the tradeoffs between decimal.Decimal and float before enabling this option. | False                  | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| partner_sp_id                     | str  | The Partner SP Id used for authentication with Ping                                                                                                                                                                                                                                                                                                                                                       | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| password                          | str  | The password to use for authentication                                                                                                                                                                                                                                                                                                                                                                    | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| port                              | Int  | The port number of the Amazon Redshift cluster                                                                                                                                                                                                                                                                                                                                                            | 5439                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| preferred_role                    | str  | The IAM role preferred for the current connection                                                                                                                                                                                                                                                                                                                                                         | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| principal_arn                     | str  | The ARN of the IAM entity (user or role) for which you are generating a policy                                                                                                                                                                                                                                                                                                                            | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| profile                           | str  | The name of a profile in a AWS credentials file that contains AWS credentials.                                                                                                                                                                                                                                                                                                                            | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| provider_name                     | str  | The name of the Redshift Native Auth Provider.                                                                                                                                                                                                                                                                                                                                                            | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| region                            | str  | The AWS region where the cluster is located                                                                                                                                                                                                                                                                                                                                                               | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| role_arn                          | str  | The Amazon Resource Name (ARN) of the role that the caller is assuming. This parameter is used by JwtCredentialsProvider. For this provider, this is a mandatory parameter.                                                                                                                                                                                                                               | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| role_session_name                 | str  | An identifier for the assumed role session. Typically, you pass the name or identifier that is associated with the user who is using your application. That way, the temporary security credentials that your application will use are associated with that user. This parameter is used by JwtCredentialsProvider. For this provider, this is an optional parameter.                                     | jwt_redshift_session   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| scope                             | str  | Scope for BrowserAzureOauth2CredentialsProvider authentication.                                                                                                                                                                                                                                                                                                                                           | ""                     | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| secret_access_key_id              | str  | The secret access key for the IAM role or IAM user configured for IAM database authentication                                                                                                                                                                                                                                                                                                             | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| serverless_acct_id                | str  | The account ID of the serverless. Default value None                                                                                                                                                                                                                                                                                                                                                      | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| serverless_work_group             | str  | The name of work group for serverless end point. Default value None.                                                                                                                                                                                                                                                                                                                                      | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| session_token                     | str  | The access key for the IAM role or IAM user configured for IAM database authentication. Not required unless temporary AWS credentials are being used.                                                                                                                                                                                                                                                     | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| ssl                               | bool | If SSL is enabled                                                                                                                                                                                                                                                                                                                                                                                         | TRUE                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| ssl_insecure                      | bool | Specifies if IDP hosts server certificate will be verified                                                                                                                                                                                                                                                                                                                                                | TRUE                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| sslmode                           | str  | The security of the connection to Amazon Redshift. verify-ca and verify-full are supported.                                                                                                                                                                                                                                                                                                               | verify_ca              | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| timeout                           | int  | The number of seconds before the connection to the server will timeout.                                                                                                                                                                                                                                                                                                                                   | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| token                             | str  | The access token required for the IdP token auth plugin.                                                                                                                                                                                                                                                                                                                                                  | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| token_type                        | str  | The token type required for the IdP token auth plugin.                                                                                                                                                                                                                                                                                                                                                    | ACCESS_TOKEN           | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| user                              | str  | The username to use for authentication                                                                                                                                                                                                                                                                                                                                                                    | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+
| web_identity_token                | str  | The OAuth 2.0 access token or OpenID Connect ID token that is provided by the identity provider. Your application must get this token by authenticating the user who is using your application with a web identity provider. This parameter is used by JwtCredentialsProvider. For this provider, this is a mandatory parameter.                                                                          | None                   | No       |
+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+

Supported Datatypes
~~~~~~~~~~~~~~~~~~~
``redshift_connector`` supports the following Amazon Redshift datatypes. ``redshift_connector`` will attempt to treat unsupported datatypes as strings.
Incoming data from Amazon Redshift is treated as follows:

+--------------------------+-------------------+
| Amazon Redshift Datatype | Python Datatype   |
+==========================+===================+
| ACLITEM                  | str               |
+--------------------------+-------------------+
| BOOLEAN                  | bool              |
+--------------------------+-------------------+
| INT8                     | int               |
+--------------------------+-------------------+
| INT4                     | int               |
+--------------------------+-------------------+
| INT2                     | int               |
+--------------------------+-------------------+
| VARCHAR                  | str               |
+--------------------------+-------------------+
| OID                      | int               |
+--------------------------+-------------------+
| REGPROC                  | int               |
+--------------------------+-------------------+
| XID                      | int               |
+--------------------------+-------------------+
| FLOAT4                   | float             |
+--------------------------+-------------------+
| FLOAT8                   | float             |
+--------------------------+-------------------+
| TEXT                     | str               |
+--------------------------+-------------------+
| CHAR                     | str               |
+--------------------------+-------------------+
| DATE                     | datetime.date     |
+--------------------------+-------------------+
| TIME                     | datetime.time     |
+--------------------------+-------------------+
| TIMETZ                   | datetime.time     |
+--------------------------+-------------------+
| TIMESTAMP                | datetime.datetime |
+--------------------------+-------------------+
| TIMESTAMPTZ              | datetime.datetime |
+--------------------------+-------------------+
| NUMERIC                  | decimal.Decimal   |
+--------------------------+-------------------+
| GEOMETRY                 | str               |
+--------------------------+-------------------+
| SUPER                    | str               |
+--------------------------+-------------------+
| VARBYTE                  | bytes             |
+--------------------------+-------------------+
| GEOGRAPHY                | str               |
+--------------------------+-------------------+

Logging
~~~~~~~~~~~~
``redshift_connector`` uses logging for providing detailed error messages regarding IdP authentication. A do-nothing handler is enabled by default as to prevent logs from being output to ``sys.stderr``.

Enable logging in your application to view logs output by ``redshift_connector`` as described in
the `documentation for Python logging module <https://docs.python.org/3/library/logging.html#/>`_.

Client Transfer Protocol
~~~~~~~~~~~~~~~~~~~~~~~~

``redshift_connector`` requests the Amazon Redshift server use the  highest transfer protocol version supported. As of v2.0.879 binary transfer protocol is requested by default. If necessary, the requested transfer protocol can be modified via the ``client_protocol_version`` parameter of ``redshift_connector.connect(...)``. Please see the Connection Parameters table for more details.


Getting Help
~~~~~~~~~~~~
- Ask a question on `Stack Overflow <https://stackoverflow.com/>`_ and tag it with redshift_connector
- Open a support ticket with `AWS Support <https://console.aws.amazon.com/support/home#/>`_
- If you may have found a bug, please `open an issue <https://github.com/aws/amazon-redshift-python-driver/issues/new>`_

Contributing
~~~~~~~~~~~~
We look forward to collaborating with you! Please read through  `CONTRIBUTING <https://github.com/aws/amazon-redshift-python-driver/blob/master/CONTRIBUTING.md#Reporting-Bugs/Feature-Requests>`_ before submitting any issues or pull requests.

Changelog Generation
~~~~~~~~~~~~~~~~~~~~
An entry in the changelog is generated upon release using `gitchangelog <https://github.com/vaab/gitchangelog>`_. Please use the configuration file, ``.gitchangelog.rc`` when generating the changelog.

Running Tests
-------------
You can run tests by using ``pytest test/unit``. This will run all unit tests. Integration tests require providing credentials for an Amazon Redshift cluster as well as IdP attributes in ``test/config.ini``.

Additional Resources
~~~~~~~~~~~~~~~~~~~~
- `LICENSE <https://github.com/aws/amazon-redshift-python-driver/blob/master/LICENSE>`_
- `Python Database API Specification v2.0 (PEP 249) <https://www.python.org/dev/peps/pep-0249/>`_
- `PostgreSQL Frontend/Backend Protocol <https://www.postgresql.org/docs/9.3/protocol.html>`_



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/aws/amazon-redshift-python-driver",
    "name": "redshift-connector",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "redshift dbapi",
    "author": "Amazon Web Services",
    "author_email": "redshift-drivers@amazon.com",
    "download_url": null,
    "platform": null,
    "description": "=======================================================\nredshift_connector\n=======================================================\n\n|Python Version| |PyPi|\n\n.. |PyPi| image:: https://img.shields.io/pypi/v/redshift_connector.svg?maxAge=432000&style=flat-square\n   :target: https://pypi.org/project/redshift_connector/\n\n.. |Python Version| image:: https://img.shields.io/badge/python->=3.6-brightgreen.svg\n   :target: https://pypi.org/project/redshift_connector/\n\n``redshift_connector`` is the Amazon Redshift connector for\nPython. Easy integration with `pandas <https://github.com/pandas-dev/pandas>`_ and `numpy <https://github.com/numpy/numpy>`_, as well as support for numerous Amazon Redshift specific features help you get the most out of your data\n\nSupported Amazon Redshift features include:\n\n- IAM authentication\n- Identity provider (IdP) authentication\n- Redshift specific data types\n\n\nThis pure Python connector implements `Python Database API Specification 2.0 <https://www.python.org/dev/peps/pep-0249/>`_.\n\n\nGetting Started\n---------------\n\nInstall from Binary\n~~~~~~~~~~~~~~~~~~~\n\n+----------------------------------------------------------------+--------------------+-----------------------------------------------------+\n| Package Manager                                                | Downloads          | Installation Command                                |\n+================================================================+====================+=====================================================+\n| `PyPi <https://pypi.org/project/redshift-connector/>`_         |  |PyPi Downloads|  | ``pip install redshift_connector``                  |\n+----------------------------------------------------------------+--------------------+-----------------------------------------------------+\n| `Conda <https://anaconda.org/conda-forge/redshift_connector>`_ |  |Conda Downloads| | ``conda install -c conda-forge redshift_connector`` |\n+----------------------------------------------------------------+--------------------+-----------------------------------------------------+\n\n.. |PyPi Downloads| image:: https://pepy.tech/badge/redshift_connector\n.. |Conda Downloads| image:: https://img.shields.io/conda/dn/conda-forge/redshift_connector.svg\n\n\nInstall from Source\n~~~~~~~~~~~~~~~~~~~\nYou may install from source by cloning this repository.\n\n.. code-block:: sh\n\n    $ git clone https://github.com/aws/amazon-redshift-python-driver.git\n    $ cd redshift_connector\n    $ pip install .\n\nTutorials\n~~~~~~~~~\n- `001 - Connecting to Amazon Redshift <https://github.com/aws/amazon-redshift-python-driver/blob/master/tutorials/001%20-%20Connecting%20to%20Amazon%20Redshift.ipynb>`_\n- `002 - Data Science Library Integrations <https://github.com/aws/amazon-redshift-python-driver/blob/master/tutorials/002%20-%20Data%20Science%20Library%20Integrations.ipynb>`_\n- `003 - Amazon Redshift Feature Support <https://github.com/aws/amazon-redshift-python-driver/blob/master/tutorials/003%20-%20Amazon%20Redshift%20Feature%20Support.ipynb>`_\n- `004 - Amazon Redshift Datatypes <https://github.com/aws/amazon-redshift-python-driver/blob/master/tutorials/004%20-%20Amazon%20Redshift%20Datatypes.ipynb>`_\n\nWe are working to add more documentation and would love your feedback. Please reach out to the team by `opening an issue <https://github.com/aws/amazon-redshift-python-driver/issues/new/choose>`__ or `starting a discussion <https://github.com/aws/amazon-redshift-python-driver/discussions/new>`_ to help us fill in the gaps in our documentation.\n\nIntegrations\n~~~~~~~~~~~~\n``redshift_connector`` integrates with various open source projects to provide an interface to Amazon Redshift. Please `open an issue <https://github.com/aws/amazon-redshift-python-driver/issues/new/choose>`__ with our project to request new integrations or get support for a ``redshift_connector`` issue seen in an existing integration.\n\n- `apache-airflow <https://github.com/apache/airflow>`_\n- `querybook <https://github.com/pinterest/querybook>`_\n- `sqlalchemy-redshift <https://github.com/sqlalchemy-redshift/sqlalchemy-redshift>`_\n\nBasic Example\n~~~~~~~~~~~~~\n.. code-block:: python\n\n    import redshift_connector\n\n    # Connects to Redshift cluster using AWS credentials\n    conn = redshift_connector.connect(\n        host='examplecluster.abc123xyz789.us-west-1.redshift.amazonaws.com',\n        database='dev',\n        user='awsuser',\n        password='my_password'\n     )\n\n    cursor: redshift_connector.Cursor = conn.cursor()\n    cursor.execute(\"create Temp table book(bookname varchar,author varchar)\")\n    cursor.executemany(\"insert into book (bookname, author) values (%s, %s)\",\n                        [\n                            ('One Hundred Years of Solitude', 'Gabriel Garc\u00eda M\u00e1rquez'),\n                            ('A Brief History of Time', 'Stephen Hawking')\n                        ]\n                      )\n    cursor.execute(\"select * from book\")\n\n    result: tuple = cursor.fetchall()\n    print(result)\n    >> (['One Hundred Years of Solitude', 'Gabriel Garc\u00eda M\u00e1rquez'], ['A Brief History of Time', 'Stephen Hawking'])\n\nEnabling autocommit\n~~~~~~~~~~~~~~~~~~~\n**Following the DB-API specification, autocommit is off by default**. It can be turned on by using the autocommit property of the connection.\n\n.. code-block:: py3\n\n    # Make sure we're not in a transaction\n    conn.rollback()\n    conn.autocommit = True\n    conn.run(\"VACUUM\")\n    conn.autocommit = False\n\n\nConfiguring paramstyle\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nParamstyle can be set on both a module and cursor level. When paramstyle is set on a module level e.g. ``redshift_connector.paramstyle = 'qmark'``, the user specified paramstyle is used for all subsequent cursors unless set on the cursor.\nWhen paramstyle is set on the cursor e.g. ```cursor.paramstyle = 'qmark'`` the user specified paramstyle is only used for that cursor object.\n\n.. code-block:: python\n\n    # setting paramstyle to qmark on a module level\n    redshift_connector.paramstyle = 'qmark'\n\n\n    with redshift_connector.connect() as conn1:\n        with conn1.cursor() as cursor1: # this cursor will use qmark paramstyle as it's been set on the module level\n            pass\n\n        with conn1.cursor() as cursor2:\n            # setting paramstyle to numeric on the cursor level only this cursor will use numeric paramstyle\n            cursor.paramstyle = 'numeric'\n\n        with conn1.cursor() as cursor3: # this cursor will use qmark paramstyle as it's been set on the module level\n            pass\n\n     with redshift_connector.connect() as conn2:\n        with conn2.cursor() as cursor1: # this cursor will use qmark paramstyle as it's been set on the module level\n            pass\n\n\nThe module level default paramstyle used is ``format``. Valid values for ``paramstyle`` include ``qmark, numeric, named, format, pyformat``. The below example shows how to use various paramstyles after the paramstyle is set on the cursor.\n\nWhen paramstyle is set to ``named`` or ``pyformat``, parameters must be passed as a Python dictionary to the ``execute()`` method. Other paramstyles require parameters to be passed as a Python tuple or list.\n\n.. code-block:: python\n\n    # qmark\n    cursor.paramstyle = 'qmark'\n    sql = 'insert into foo(bar, jar) VALUES(?, ?)'\n    cursor.execute(sql, (1, \"hello world\"))\n\n    # numeric\n    cursor.paramstyle = 'numeric'\n    sql = 'insert into foo(bar, jar) VALUES(:1, :2)'\n    cursor.execute(sql, (1, \"hello world\"))\n\n    # named\n    cursor.paramstyle = 'named'\n    sql = 'insert into foo(bar, jar) VALUES(:p1, :p2)'\n    cursor.execute(sql, {\"p1\":1, \"p2\":\"hello world\"})\n\n    # format\n    cursor.paramstyle = 'format'\n    sql = 'insert into foo(bar, jar) VALUES(%s, %s)'\n    cursor.execute(sql, (1, \"hello world\"))\n\n    # pyformat\n    cursor.paramstyle = 'pyformat'\n    sql = 'insert into foo(bar, jar) VALUES(%(bar)s, %(jar)s)'\n    cursor.execute(sql, {\"bar\": 1, \"jar\": \"hello world\"})\n\n\nException Handling\n~~~~~~~~~~~~~~~~~~~\n``redshift_connector`` uses the guideline for exception handling specified in the `Python DB-API <https://www.python.org/dev/peps/pep-0249/#exceptions>`_. For exception definitions, please see `redshift_connector/error.py <https://github.com/aws/amazon-redshift-python-driver/blob/master/redshift_connector/error.py>`_\n\nExample using IAM Credentials\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nIAM Credentials can be supplied directly to ``connect(...)`` using an AWS profile as shown below:\n\n.. code-block:: python\n\n    import redshift_connector\n\n    # Connects to Redshift cluster using IAM credentials from default profile defined in ~/.aws/credentials\n    conn = redshift_connector.connect(\n        iam=True,\n        database='dev',\n        db_user='awsuser',\n        password='',\n        user='',\n        cluster_identifier='examplecluster',\n        profile='default'\n     )\n\n.. code-block:: bash\n\n    # ~/.aws/credentials\n    [default]\n    aws_access_key_id=\"my_aws_access_key_id\"\n    aws_secret_access_key=\"my_aws_secret_access_key\"\n    aws_session_token=\"my_aws_session_token\"\n\n    # ~/.aws/config\n    [default]\n    region=us-west-2\n\nIf a region is not provided in `~/.aws/config` or you would like to override its value, `region` may be passed to ``connect(...)``.\n\nAlternatively, IAM credentials can be supplied directly to ``connect(...)`` using AWS credentials as shown below:\n\n.. code-block:: python\n\n    import redshift_connector\n\n    # Connects to Redshift cluster using IAM credentials from default profile defined in ~/.aws/credentials\n    conn = redshift_connector.connect(\n        iam=True,\n        database='dev',\n        db_user='awsuser',\n        password='',\n        user='',\n        cluster_identifier='examplecluster',\n        access_key_id=\"my_aws_access_key_id\",\n        secret_access_key=\"my_aws_secret_access_key\",\n        session_token=\"my_aws_session_token\",\n        region=\"us-east-2\"\n     )\n\nIntegration with pandas\n~~~~~~~~~~~~~~~~~~~~~~~\n\nRetrieving query results as a ``pandas.DataFrame``\n\n.. code-block:: python\n\n    import pandas\n    cursor.execute(\"create Temp table book(bookname varchar,author varchar)\")\n    cursor.executemany(\"insert into book (bookname, author) values (%s, %s)\",\n                       [\n                           ('One Hundred Years of Solitude', 'Gabriel Garc\u00eda M\u00e1rquez'),\n                           ('A Brief History of Time', 'Stephen Hawking')\n\n                       ])\n    cursor.execute(\"select * from book\")\n    result: pandas.DataFrame = cursor.fetch_dataframe()\n    print(result)\n    >>                         bookname                 author\n    >> 0  One Hundred Years of Solitude  Gabriel Garc\u00eda M\u00e1rquez\n    >> 1        A Brief History of Time         Stephen Hawking\n\n\nInsert data stored in a ``pandas.DataFrame`` into an Amazon Redshift table\n\n.. code-block:: python\n\n    import numpy as np\n    import pandas as pd\n\n    df = pd.DataFrame(\n        np.array(\n            [\n                [\"One Hundred Years of Solitude\", \"Gabriel Garc\u00eda M\u00e1rquez\"],\n                [\"A Brief History of Time\", \"Stephen Hawking\"],\n            ]\n        ),\n        columns=[\"bookname\", \"author\u200e\"],\n    )\n    with conn.cursor() as cursor:\n        cursor.write_dataframe(df, \"book\")\n        cursor.execute(\"select * from book; \")\n        result = cursor.fetchall()\n\n\nIntegration with numpy\n~~~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n    import numpy\n    cursor.execute(\"select * from book\")\n\n    result: numpy.ndarray = cursor.fetch_numpy_array()\n    print(result)\n    >> [['One Hundred Years of Solitude' 'Gabriel Garc\u00eda M\u00e1rquez']\n    >>  ['A Brief History of Time' 'Stephen Hawking']]\n\nQuery using functions\n~~~~~~~~~~~~~~~~~~~~~\n.. code-block:: python\n\n    cursor.execute(\"SELECT CURRENT_TIMESTAMP\")\n    print(cursor.fetchone())\n    >> [datetime.datetime(2020, 10, 26, 23, 3, 54, 756497, tzinfo=datetime.timezone.utc)]\n\n\nConnection Parameters\n~~~~~~~~~~~~~~~~~~~~~\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| Name                              | Type | Description                                                                                                                                                                                                                                                                                                                                                                                               | Default Value          | Required |\n+===================================+======+===========================================================================================================================================================================================================================================================================================================================================================================================================+========================+==========+\n| access_key_id                     | str  | The access key for the IAM role or IAM user configured for IAM database authentication                                                                                                                                                                                                                                                                                                                    | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| allow_db_user_override            | bool | True specifies the driver uses the DbUser value from the SAML assertion while False indicates the value in the DbUser connection parameter is used                                                                                                                                                                                                                                                        | FALSE                  | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| app_name                          | str  | The name of the IdP application used for authentication                                                                                                                                                                                                                                                                                                                                                   | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| auth_profile                      | str  | The name of an Amazon Redshift Authentication profile having connection properties as JSON. See the RedshiftProperty class to learn how connection parameters should be named.                                                                                                                                                                                                                            | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| auto_create                       | bool | Indicates whether the user should be created if they do not exist                                                                                                                                                                                                                                                                                                                                         | FALSE                  | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| client_id                         | str  | The client id from Azure IdP                                                                                                                                                                                                                                                                                                                                                                              | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| client_secret                     | str  | The client secret from Azure IdP                                                                                                                                                                                                                                                                                                                                                                          | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| cluster_identifier                | str  | The cluster identifier of the Amazon Redshift Cluster                                                                                                                                                                                                                                                                                                                                                     | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| credentials_provider              | str  | The IdP that will be used for authenticating with Amazon Redshift.                                                                                                                                                                                                                                                                                                                                        | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| database                          | str  | The name of the database to connect to                                                                                                                                                                                                                                                                                                                                                                    | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| database_metadata_current_db_only | bool | Indicates if application supports multi-database datashare catalogs. Default value of  True indicates application does not support multi-database datashare catalogs for backwards compatibility                                                                                                                                                                                                          | TRUE                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| db_groups                         | list | A comma-separated list of existing database group names that the DbUser joins for the current session                                                                                                                                                                                                                                                                                                     | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| db_user                           | str  | The user ID to use with Amazon Redshift                                                                                                                                                                                                                                                                                                                                                                   | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| endpoint_url                      | str  | The Amazon Redshift endpoint url. This option is only used by AWS internal teams.                                                                                                                                                                                                                                                                                                                         | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| group_federation                  | bool | Use the IdP Groups in the Redshift. Default value False.                                                                                                                                                                                                                                                                                                                                                  | False                  | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| host                              | str  | The hostname of Amazon Redshift cluster                                                                                                                                                                                                                                                                                                                                                                   | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| iam                               | bool | If IAM Authentication is enabled                                                                                                                                                                                                                                                                                                                                                                          | FALSE                  | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| iam_disable_cache                 | bool | This option specifies whether the IAM credentials are cached. By default the IAM credentials are cached. This improves performance when requests to the API gateway are throttled.                                                                                                                                                                                                                        | FALSE                  | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| identity_namespace                | str  | The identity namespace to be used for the IdC browser auth plugin and IdP token auth plugin. It is an optional value if there is only one IdC instance existing or if default identity namespace is set on the cluster - else it is required.                                                                                                                                                             | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| idp_response_timeout              | int  | The timeout for retrieving SAML assertion from IdP                                                                                                                                                                                                                                                                                                                                                        | 120                    | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| idp_tenant                        | str  | The IdP tenant                                                                                                                                                                                                                                                                                                                                                                                            | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| listen_port                       | int  | The listen port IdP will send the SAML assertion to                                                                                                                                                                                                                                                                                                                                                       | 7890                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| login_to_rp                       | str  | Only for AdfsCredentialsProvider. Used to specify the loginToRp when performing IdpInitiatedSignOn as apart of form based authentication.                                                                                                                                                                                                                                                                 | urn:amazon:webservices | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| login_url                         | str  | The SSO Url for the IdP                                                                                                                                                                                                                                                                                                                                                                                   | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| max_prepared_statements           | int  | The maximum number of prepared statements that can be open at once                                                                                                                                                                                                                                                                                                                                        | 1000                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| numeric_to_float                  | bool | Specifies if NUMERIC datatype values will be converted from decimal.Decimal to float. By default NUMERIC values are received as decimal.Decimal. Enabling this option is not recommended for use cases which prefer the most precision as results may be rounded. Please reference the Python docs on decimal.Decimal to see the tradeoffs between decimal.Decimal and float before enabling this option. | False                  | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| partner_sp_id                     | str  | The Partner SP Id used for authentication with Ping                                                                                                                                                                                                                                                                                                                                                       | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| password                          | str  | The password to use for authentication                                                                                                                                                                                                                                                                                                                                                                    | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| port                              | Int  | The port number of the Amazon Redshift cluster                                                                                                                                                                                                                                                                                                                                                            | 5439                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| preferred_role                    | str  | The IAM role preferred for the current connection                                                                                                                                                                                                                                                                                                                                                         | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| principal_arn                     | str  | The ARN of the IAM entity (user or role) for which you are generating a policy                                                                                                                                                                                                                                                                                                                            | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| profile                           | str  | The name of a profile in a AWS credentials file that contains AWS credentials.                                                                                                                                                                                                                                                                                                                            | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| provider_name                     | str  | The name of the Redshift Native Auth Provider.                                                                                                                                                                                                                                                                                                                                                            | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| region                            | str  | The AWS region where the cluster is located                                                                                                                                                                                                                                                                                                                                                               | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| role_arn                          | str  | The Amazon Resource Name (ARN) of the role that the caller is assuming. This parameter is used by JwtCredentialsProvider. For this provider, this is a mandatory parameter.                                                                                                                                                                                                                               | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| role_session_name                 | str  | An identifier for the assumed role session. Typically, you pass the name or identifier that is associated with the user who is using your application. That way, the temporary security credentials that your application will use are associated with that user. This parameter is used by JwtCredentialsProvider. For this provider, this is an optional parameter.                                     | jwt_redshift_session   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| scope                             | str  | Scope for BrowserAzureOauth2CredentialsProvider authentication.                                                                                                                                                                                                                                                                                                                                           | \"\"                     | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| secret_access_key_id              | str  | The secret access key for the IAM role or IAM user configured for IAM database authentication                                                                                                                                                                                                                                                                                                             | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| serverless_acct_id                | str  | The account ID of the serverless. Default value None                                                                                                                                                                                                                                                                                                                                                      | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| serverless_work_group             | str  | The name of work group for serverless end point. Default value None.                                                                                                                                                                                                                                                                                                                                      | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| session_token                     | str  | The access key for the IAM role or IAM user configured for IAM database authentication. Not required unless temporary AWS credentials are being used.                                                                                                                                                                                                                                                     | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| ssl                               | bool | If SSL is enabled                                                                                                                                                                                                                                                                                                                                                                                         | TRUE                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| ssl_insecure                      | bool | Specifies if IDP hosts server certificate will be verified                                                                                                                                                                                                                                                                                                                                                | TRUE                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| sslmode                           | str  | The security of the connection to Amazon Redshift. verify-ca and verify-full are supported.                                                                                                                                                                                                                                                                                                               | verify_ca              | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| timeout                           | int  | The number of seconds before the connection to the server will timeout.                                                                                                                                                                                                                                                                                                                                   | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| token                             | str  | The access token required for the IdP token auth plugin.                                                                                                                                                                                                                                                                                                                                                  | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| token_type                        | str  | The token type required for the IdP token auth plugin.                                                                                                                                                                                                                                                                                                                                                    | ACCESS_TOKEN           | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| user                              | str  | The username to use for authentication                                                                                                                                                                                                                                                                                                                                                                    | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n| web_identity_token                | str  | The OAuth 2.0 access token or OpenID Connect ID token that is provided by the identity provider. Your application must get this token by authenticating the user who is using your application with a web identity provider. This parameter is used by JwtCredentialsProvider. For this provider, this is a mandatory parameter.                                                                          | None                   | No       |\n+-----------------------------------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------+----------+\n\nSupported Datatypes\n~~~~~~~~~~~~~~~~~~~\n``redshift_connector`` supports the following Amazon Redshift datatypes. ``redshift_connector`` will attempt to treat unsupported datatypes as strings.\nIncoming data from Amazon Redshift is treated as follows:\n\n+--------------------------+-------------------+\n| Amazon Redshift Datatype | Python Datatype   |\n+==========================+===================+\n| ACLITEM                  | str               |\n+--------------------------+-------------------+\n| BOOLEAN                  | bool              |\n+--------------------------+-------------------+\n| INT8                     | int               |\n+--------------------------+-------------------+\n| INT4                     | int               |\n+--------------------------+-------------------+\n| INT2                     | int               |\n+--------------------------+-------------------+\n| VARCHAR                  | str               |\n+--------------------------+-------------------+\n| OID                      | int               |\n+--------------------------+-------------------+\n| REGPROC                  | int               |\n+--------------------------+-------------------+\n| XID                      | int               |\n+--------------------------+-------------------+\n| FLOAT4                   | float             |\n+--------------------------+-------------------+\n| FLOAT8                   | float             |\n+--------------------------+-------------------+\n| TEXT                     | str               |\n+--------------------------+-------------------+\n| CHAR                     | str               |\n+--------------------------+-------------------+\n| DATE                     | datetime.date     |\n+--------------------------+-------------------+\n| TIME                     | datetime.time     |\n+--------------------------+-------------------+\n| TIMETZ                   | datetime.time     |\n+--------------------------+-------------------+\n| TIMESTAMP                | datetime.datetime |\n+--------------------------+-------------------+\n| TIMESTAMPTZ              | datetime.datetime |\n+--------------------------+-------------------+\n| NUMERIC                  | decimal.Decimal   |\n+--------------------------+-------------------+\n| GEOMETRY                 | str               |\n+--------------------------+-------------------+\n| SUPER                    | str               |\n+--------------------------+-------------------+\n| VARBYTE                  | bytes             |\n+--------------------------+-------------------+\n| GEOGRAPHY                | str               |\n+--------------------------+-------------------+\n\nLogging\n~~~~~~~~~~~~\n``redshift_connector`` uses logging for providing detailed error messages regarding IdP authentication. A do-nothing handler is enabled by default as to prevent logs from being output to ``sys.stderr``.\n\nEnable logging in your application to view logs output by ``redshift_connector`` as described in\nthe `documentation for Python logging module <https://docs.python.org/3/library/logging.html#/>`_.\n\nClient Transfer Protocol\n~~~~~~~~~~~~~~~~~~~~~~~~\n\n``redshift_connector`` requests the Amazon Redshift server use the  highest transfer protocol version supported. As of v2.0.879 binary transfer protocol is requested by default. If necessary, the requested transfer protocol can be modified via the ``client_protocol_version`` parameter of ``redshift_connector.connect(...)``. Please see the Connection Parameters table for more details.\n\n\nGetting Help\n~~~~~~~~~~~~\n- Ask a question on `Stack Overflow <https://stackoverflow.com/>`_ and tag it with redshift_connector\n- Open a support ticket with `AWS Support <https://console.aws.amazon.com/support/home#/>`_\n- If you may have found a bug, please `open an issue <https://github.com/aws/amazon-redshift-python-driver/issues/new>`_\n\nContributing\n~~~~~~~~~~~~\nWe look forward to collaborating with you! Please read through  `CONTRIBUTING <https://github.com/aws/amazon-redshift-python-driver/blob/master/CONTRIBUTING.md#Reporting-Bugs/Feature-Requests>`_ before submitting any issues or pull requests.\n\nChangelog Generation\n~~~~~~~~~~~~~~~~~~~~\nAn entry in the changelog is generated upon release using `gitchangelog <https://github.com/vaab/gitchangelog>`_. Please use the configuration file, ``.gitchangelog.rc`` when generating the changelog.\n\nRunning Tests\n-------------\nYou can run tests by using ``pytest test/unit``. This will run all unit tests. Integration tests require providing credentials for an Amazon Redshift cluster as well as IdP attributes in ``test/config.ini``.\n\nAdditional Resources\n~~~~~~~~~~~~~~~~~~~~\n- `LICENSE <https://github.com/aws/amazon-redshift-python-driver/blob/master/LICENSE>`_\n- `Python Database API Specification v2.0 (PEP 249) <https://www.python.org/dev/peps/pep-0249/>`_\n- `PostgreSQL Frontend/Backend Protocol <https://www.postgresql.org/docs/9.3/protocol.html>`_\n\n\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "Redshift interface library",
    "version": "2.1.1",
    "project_urls": {
        "Homepage": "https://github.com/aws/amazon-redshift-python-driver"
    },
    "split_keywords": [
        "redshift",
        "dbapi"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d59eeae3a4fc7c0e90b31abb9e268b445667290e5e45ec33f75bf294c6ed8e07",
                "md5": "1cc8620df502ce341d386709fe3949be",
                "sha256": "540c4674859bb2e9668abbcfb64d346cff9d11ed2707533efd28717dbff523c0"
            },
            "downloads": -1,
            "filename": "redshift_connector-2.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1cc8620df502ce341d386709fe3949be",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 125048,
            "upload_time": "2024-04-15T16:12:18",
            "upload_time_iso_8601": "2024-04-15T16:12:18.041393Z",
            "url": "https://files.pythonhosted.org/packages/d5/9e/eae3a4fc7c0e90b31abb9e268b445667290e5e45ec33f75bf294c6ed8e07/redshift_connector-2.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-15 16:12:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "aws",
    "github_project": "amazon-redshift-python-driver",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "redshift-connector"
}
        
Elapsed time: 0.25872s