Skip to content

Conversation

@leodrivera
Copy link

Description

This PR fixes a deprecation warning by replacing the deprecated dbapi() classmethod with import_dbapi() in both Redshift dialect classes. SQLAlchemy has deprecated dbapi() in favor of import_dbapi() to better reflect the method's purpose.

Problem

When using this library with SQLAlchemy, users encounter the following deprecation warning:

SADeprecationWarning: The dbapi() classmethod on dialect classes has been renamed to import_dbapi().
Implement an import_dbapi() classmethod directly on class <class 'sqlalchemy_redshift.dialect.RedshiftDialect_psycopg2'>
to remove this warning; the old .dbapi() classmethod may be maintained for backwards compatibility.

This was reported in: great-expectations/great_expectations#11141

Solution

  • Renamed dbapi() to import_dbapi() in Psycopg2RedshiftDialectMixin
  • Renamed dbapi() to import_dbapi() in RedshiftDialect_redshift_connector
  • Added docstrings to both import_dbapi() methods explaining their purpose

Changes

  • sqlalchemy_redshift/dialect.py: Updated both dialect classes to use import_dbapi() instead of dbapi()

SQLAlchemy has deprecated the dbapi() classmethod in favor of
import_dbapi(). This change updates both dialect classes to use the
new method name, eliminating the SADeprecationWarning.

Fixes: great-expectations/great_expectations#11141

Changes:
- Rename dbapi() to import_dbapi() in Psycopg2RedshiftDialectMixin
- Rename dbapi() to import_dbapi() in RedshiftDialect_redshift_connector
- Add docstrings to both import_dbapi() methods explaining their purpose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant