-
Notifications
You must be signed in to change notification settings - Fork 403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I get a cryptic KeyError when I tryto use asyncpg's executemany method #807
Comments
|
Thanks, it looks like I misunderstood the argument types. Yes, I think list of dicts, list of lists, and list of tuples should all be supported, but I know what I did wrong now. |
Supporting mappings would be confusing, because the iteration is done over keys in Python. It would also be inconsistent with the handling of query arguments in Postgres/asyncpg in general as they're inherently positional. |
yes, perhaps all that's needed is a clearer error message in case the user passes in the wrong type of record? |
Definitely. |
This adds a check that elements of sequence passed to `executemany()` are proper sequences themselves and notes the offending sequence element number in the exception message. For example: await self.con.executemany( "INSERT INTO exmany (b) VALUES($1)" [(0,), ("bad",)], ) DataError: invalid input for query argument $1 in element #1 of executemany() sequence: 'bad' ('str' object cannot be interpreted as an integer) Fixes: #807
This adds a check that elements of sequence passed to `executemany()` are proper sequences themselves and notes the offending sequence element number in the exception message. For example: await self.con.executemany( "INSERT INTO exmany (b) VALUES($1)" [(0,), ("bad",)], ) DataError: invalid input for query argument $1 in element #1 of executemany() sequence: 'bad' ('str' object cannot be interpreted as an integer) Fixes: #807
I'm trying to execute this code:
where query is:
and records consists of the following data:
When I try to execute this code, I get a rather cryptic traceback. can anybody explain what it means? What am I doing wrong?
The text was updated successfully, but these errors were encountered: