question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sqlalchemy redshift TypeError: unhashable type: 'list' version 1.3.11

See original GitHub issue

After upgrading to 1.3.11, I am getting the following error when trying to reflect a AWS Redshift table: TypeError: unhashable type: 'list'. I am using the sqlalchemy-redshift dialect.

from sqlalchemy import create_engine, Table, MetaData
connect_args = dict(sslmode="verify-ca", keepalives_idle=200)
uri = 'redshift+psycopg2://<user>:<pass>@redshift-cluster:5439/my-db'
engine = create_engine(uri, connect_args=connect_args)
meta = MetaData()
t = Table('my_table', meta, schema='my_schema', autoload=True, autoload_with=engine)

If I downgrade to 1.3.10 then it works fine. The only data types in the table I am trying to reflect are bigint, timestamp, date, and varchar.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
zzzeekcommented, Nov 15, 2019

they (sqlalchemy-redshift) are hitting a hard change I had to make to fix #4955. so what is happening is that they have options like “sortkey” which they are reflecting at https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/blob/master/sqlalchemy_redshift/dialect.py#L583 . these options get passed back into methods like get_coulmns(), for them it is at https://github.com/sqlalchemy-redshift/sqlalchemy-redshift/blob/master/sqlalchemy_redshift/dialect.py#L418, and the @reflection.cache they are using, which is optional, now caches on all the keyword arguments, including the list-based “sortkey” and others we see coming from table arguments.

so redshift has to either a. ensure table kwargs like sortkey and others are hashable, usually by making them into tuples or b. don’t use @reflection.cache.

they also should look into having a CI build that tests against the latest SQLAlchemy version.

0reactions
anthnyprschkacommented, Oct 10, 2021

hi @zzzeek i have similar issue with mysql where it returns unhashable type: 'bytearray' when i try to reflect a table. any ideas how to solve that?

Read more comments on GitHub >

github_iconTop Results From Across the Web

sqlalchemy-redshift - PyPI
Fix unhashable type error for sortkey reflection in SQLAlchemy >= 1.3.11 (Issue #180). Expose supported types for import from the dialect (Issue #181)....
Read more >
unhashable type: 'list' when using sqlalchemy and pandas df ...
I'm trying to read using sqlalchemy and then insert into Oracle DB. pd.read_sql_query works fine and when I execute display (df), ...
Read more >
sqlalchemy-redshift Changelog - pyup.io
PyUp actively tracks 467,103 Python packages for vulnerabilities to keep your ... Fix unhashable type error for sortkey reflection in SQLAlchemy >= 1.3.11...
Read more >
Cannot retrieve PostgreSQL array column with session.query()
TypeError : unhashable type: 'list' Full code : import os from sqlalchemy import create_engine, Table, Integer, MetaData, Column from sqlalchemy.orm import ...
Read more >
httpry-0.1.8-1.el6 - Pulp Repository Index
Changes since version '3.4.7′ are: * Fix database corruption- TypeError: unhashable type: 'list' * Fix bug in abandon changes and quit * Fix...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found