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.

records python3 is not compatible with new sqlalchemy release 1.4.0

See original GitHub issue

I am getting the following error when trying to parse the results of a query. Digging into this more, this seems to be an issue with compatibility with the new sqlalchemy that was released this week (March 14, 2021).

There doesn’t appear to be any version restrictions defined in the setup.py which allows things like pip to grab the newer 1.4.0 release which is not usable.

The easiest fix would be to update the setup.py to ensure sqlalchemy < 1.4 is used.

Example code:

db_reader = records.Database(DB_URL)
rows = db_reader.query(SQL, fetchall=True, **kwargs)
row_dict = {key: check_type(value) for (key, value) in dict(rows[0]).items()}

Example error:

AttributeError: 'RMKeyView' object has no attribute 'index'

This is thrown from the following line. https://github.com/kenreitz42/records/blob/c23f5770127826665402e17ab4e115127b5489c5/records.py#L54

Seems like the sqlalchemy 1.4.0 changes some interfaces. When I reverted to sqlalchemy 1.3.23, it appears to work again.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:8
  • Comments:6

github_iconTop GitHub Comments

3reactions
kolapapacommented, Mar 24, 2021

I have the same problem. Im using flask-sqlalchemy==2.4.3 in requirements.txt. I didn’t pinned the version of sqlalchemy. And Flask-sqlalchemy pinned the sqlalchemy with >=1.2 in prod(at 20210208 published):

pip freeze | grep 'SQLAlchemy'
SQLAlchemy==1.3.23

in prod(at 20210324 published):

pip freeze | grep 'SQLAlchemy'
SQLAlchemy==1.4.2

Temporary solutions is pinned sqlalchemy

SQLAlchemy==1.3.23
1reaction
jdonbochcommented, Mar 17, 2021

Perhaps this is a regression on the part of sqlalchemy, they released a patched 1.4.1 today that fixed many regressions but this still seems to be an issue even when using 1.4.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

records python3 is not compatible with new sqlalchemy ...
I am getting the following error when trying to parse the results of a query. Digging into this more, this seems to be...
Read more >
Records is not compatible with Python 3.8+ #214 - GitHub
records python3 is not compatible with new sqlalchemy release 1.4.0 (#208) #208 but versions of sqlalchemy older than 1.4.0 are not ...
Read more >
What's New in SQLAlchemy 1.4?
Python 2.7 is still supported, however the SQLAlchemy 1.4 series will be the last series to support Python 2.
Read more >
SQLAlchemy: create_engine() error on deprecations.py
My SQLAlchemy version on my local with GCP has the same version. Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages ...
Read more >
pandas.DataFrame.to_sql — pandas 1.5.2 documentation
Write records stored in a DataFrame to a SQL database. Databases supported by SQLAlchemy [1] are supported. ... sqlite3 or SQLAlchemy. New in...
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