KeyError: '_data'
See original GitHub issueWith
- Python 3.9.2
- sqlalchemy 1.4.0
I get this error:
Traceback (most recent call last):
File "/home/julian/src/bruce-leads/.venv/lib/python3.9/site-packages/sqlalchemy/sql/base.py", line 1104, in __getattr__
return self._index[key]
KeyError: '_data'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/julian/src/bruce-leads/.venv/bin/eralchemy", line 8, in <module>
sys.exit(cli())
File "/home/julian/src/bruce-leads/.venv/lib/python3.9/site-packages/eralchemy/main.py", line 31, in cli
render_er(
File "/home/julian/src/bruce-leads/.venv/lib/python3.9/site-packages/eralchemy/main.py", line 231, in render_er
tables, relationships = all_to_intermediary(input, schema=schema)
File "/home/julian/src/bruce-leads/.venv/lib/python3.9/site-packages/eralchemy/main.py", line 147, in all_to_intermediary
return database_to_intermediary(filename_or_input, schema=schema)
File "/home/julian/src/bruce-leads/.venv/lib/python3.9/site-packages/eralchemy/sqla.py", line 82, in database_to_intermediary
return declarative_to_intermediary(Base)
File "/home/julian/src/bruce-leads/.venv/lib/python3.9/site-packages/eralchemy/sqla.py", line 61, in declarative_to_intermediary
return metadata_to_intermediary(base.metadata)
File "/home/julian/src/bruce-leads/.venv/lib/python3.9/site-packages/eralchemy/sqla.py", line 54, in metadata_to_intermediary
tables = [table_to_intermediary(table) for table in metadata.tables.values()]
File "/home/julian/src/bruce-leads/.venv/lib/python3.9/site-packages/eralchemy/sqla.py", line 54, in <listcomp>
tables = [table_to_intermediary(table) for table in metadata.tables.values()]
File "/home/julian/src/bruce-leads/.venv/lib/python3.9/site-packages/eralchemy/sqla.py", line 49, in table_to_intermediary
return Table(name=table.fullname, columns=[column_to_intermediary(col) for col in table.c._data.values()])
File "/home/julian/src/bruce-leads/.venv/lib/python3.9/site-packages/sqlalchemy/sql/base.py", line 1106, in __getattr__
util.raise_(AttributeError(key), replace_context=err)
File "/home/julian/src/bruce-leads/.venv/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 180, in raise_
raise exception
AttributeError: _data
I have investigated to fix it for sqlachemy but don’t know about backwards compat.
needs to be replaced with:
columns=[column_to_intermediary(col) for col in table.c._colset]
I can create a tested PR if you are willing to merge it.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:46
- Comments:10
Top Results From Across the Web
Python 2.7.6, KeyError: 'data' when trying to run script
KeyError means that there is no such key in a dict object. Therefore it means your file does not contain JSON data structure...
Read more >Python KeyError Exceptions and How to Handle Them
Python's official documentation says that the KeyError is raised when a mapping key is accessed and isn't found in the mapping. A mapping...
Read more >What is KeyError in Python? Dictionary and Handling Them
The mapping logic is a data structure that maps one set of data to significant others. Hence, it is an error, which is...
Read more >KeyError Pandas – How To Fix - Data Independent
Pandas KeyError - This annoying error means that Pandas can not find your column name in your dataframe. Here's how to fix this...
Read more >KeyError: 'data' - Academic Research - Twitter Developers
KeyError : 'data' ... I tried to collect all the tweets matching my requirement within one month. In the begining the code works...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Another workaround, if you don’t need 1.4 (release notes on docs.sqlalchemy.org), pinning
sqlalchemy<1.4
would fix this. To test:pip install 'sqlalchemy<1.4'
columns=[column_to_intermediary(col) for col in table.c._colset] is still needful with