amazon-redshift-python-driver icon indicating copy to clipboard operation
amazon-redshift-python-driver copied to clipboard

Feature request: `autocommit` as connector `__init__` property

Open avneeshn opened this issue 2 years ago • 2 comments

Currently, to set autocommit to True, we have to explicitly run:

connection.autocommit = True

Is there a way to pass autocommit as a property to the connector constructor? Something like:

redshift_connector.connect({
   autocommit=True,
   **connection_params
})

We are trying to build an SQL client for our customers with Redshift as one of the underlying data-sources. It would be much cleaner this way avoiding unnecessary if-else conditioning.

avneeshn avatar Dec 27 '23 23:12 avneeshn

Hi @avneeshn , thank you for reaching out with this feature request. Would setting autocommit on the module level work for your use case? Setting autocommit=True on the module level would enable autocommit for subsequent connections. For example

import redshift_connector
redshift_connector.autocommit = True

redshift_connector.connect({ # autocommit is set to True, as specified on the redshift_connector module
   **connection_params
})

redshift_connector.connect({ # again, autocommit is set to True, as specified on the redshift_connector module
   **connection_params
})

Brooke-white avatar Jan 10 '24 22:01 Brooke-white

That would not work for our case. We are creating and maintaining multiple connections so we need a connection-level autocommit property

avneeshn avatar Jan 17 '24 21:01 avneeshn