CursorDebugWrapper should allow using iterators/generators for executemany().
|Reported by:||MockSoul||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.0|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||yes||Patch needs improvement:||yes|
executemany on cursors can have a little speedup on huge lists if developer sends iterators or generators as args. Thus, they will have no len. CursorDebugWrapper tries to determine length for only one reason: put a record about number of executed queries into connection.queries.
It's good idea probably to determine if args have no len -- dont put info about amount of executed queries into connection.queries.
Right now I can do connection.cursor().cursor.executemany(sql, iterator) for that purpose. I mean -- python db wrappers usually allow iterators in executemany's args. Another ugly way right now - catch TypeError and silently ignore. This is because django do len() after calling executemany on underlying cursor =). Non-pythonic, yeah?
Change History (9)
comment:1 Changed 5 years ago by MockSoul
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
comment:4 Changed 5 years ago by jacob
- Triage Stage changed from Unreviewed to Design decision needed
comment:7 Changed 2 years ago by aaugustin
- Needs tests set
- Patch needs improvement set
- Triage Stage changed from Design decision needed to Accepted
comment:8 Changed 2 years ago by aaugustin
- Resolution set to fixed
- Status changed from new to closed