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.

Cannot unpack Row instance

See original GitHub issue

Describe the bug mypy is complaining about unpacking Row object, even though it works.

To Reproduce

test_table = Table(
    "test_table",
    metadata,
    Column("i", UUID(as_uuid=True), nullable=False, primary_key=True),
    Column("x", UUID(as_uuid=True), index=True),
    Column("y", UUID(as_uuid=True), index=True),
)
query = test_table.select()
async with engine.connect() as connection:
  result = await connection.execute(query)
row = result.fetchone()
if row:
  my_dict = {**row}

Error

Argument after ** must be a mapping, not "Row"

Versions.

  • OS: Linux Mint 19.3 Cinnamon
  • Python: 3.7.10
  • SQLAlchemy: 1.4.15
  • Database: PostgreSQL
  • DBAPI: asyncpg

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bryanforbescommented, May 19, 2021

I’d have to look into it, but off the top of my head I don’t know of a way to do it.

0reactions
zzzeekcommented, May 19, 2021

Well, that’s true. Now I am biased since I know I should move away from treating Row as Mapping.

Just a note, there seem to be no deprecation warning in my case. 😦

you need to turn on SQLALCHEMY_WARN_20 and also use Python -Walways or equivalent: https://docs.sqlalchemy.org/en/14/changelog/migration_20.html#migration-to-2-0-step-two-turn-on-removedin20warnings

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: cannot unpack non-iterable NoneType object
You get this error when you perform a multiple assignment to None (which is of NoneType ). For instance: X_train, y_train, X_test, y_test...
Read more >
TypeError cannot unpack non-iterable NoneType object
Hello,. The “TypeError: cannot unpack non-iterable NoneType object” error is raised when you try to unpack values from one that is equal to...
Read more >
Typeerror: cannot unpack non-iterable nonetype object
This error was raised because we tried to unpack a None object. The simplest way around this is to not assign names.sort() as...
Read more >
cannot unpack non-iterable NoneType object -returning a tuple
My understanding from other posts is that this occurs when trying to populate a tuple with only one value or the function doesn't...
Read more >
Subset a Data Frame
For example, to subset the d data frame only by rows, the general form reduces to ... the missing data values are not...
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