Skip to content

Fix redshift_connector dialect column encoding#255

Merged
Brooke-white merged 2 commits into
sqlalchemy-redshift:mainfrom
Brooke-white:fix-fetch-column-desc
Jul 18, 2022
Merged

Fix redshift_connector dialect column encoding#255
Brooke-white merged 2 commits into
sqlalchemy-redshift:mainfrom
Brooke-white:fix-fetch-column-desc

Conversation

@Brooke-white

@Brooke-white Brooke-white commented Jul 12, 2022

Copy link
Copy Markdown
Contributor

Fixes #254

redshift_connector's release 2.0.908 changes the DBAPI method Cursor.description to return column names as str rather than bytes.

Refactor(cursor, description): return column label as str. [Brooke White]

This breaks the sqlalchemy-redshift dialect for redshift_connector as it sets description_encoding="uses_encoding" here. This attribute is used to determine if a sqlalchemy method for converting the column names from bytes to str should be called.

Since redshift_connector returns a str, we shouldn't set description_encoding="uses_encoding" unless using an older version (<= 2.0.908).

A similar fix was made for the pg8000 sqlalchemy dialect: sqlalchemy/sqlalchemy@b2f2bf1

Related issue aws/amazon-redshift-python-driver#116

Todos

  • MIT compatible
  • Tests
  • Documentation
  • Updated CHANGES.rst

@Brooke-white Brooke-white changed the title fix(dialect): set description_encoding based on driver version Fix redshift_connector dialect column encoding Jul 12, 2022
@Brooke-white Brooke-white requested a review from jklukas July 12, 2022 18:04

@jklukas jklukas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good. Thanks for the full description of context for the change.

@Brooke-white Brooke-white merged commit 2a7896b into sqlalchemy-redshift:main Jul 18, 2022
jwaterworth pushed a commit to jwaterworth/sqlalchemy-redshift that referenced this pull request Aug 5, 2022
* fix(dialect): set description_encoding based on driver version

* Update CHANGES.rst
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.

Unable to open connection when using redshift_connector==2.0.908

2 participants