Executemany throws ProgrammingError

Bug #948063 reported by Giovanni Luca Ciampaglia on 2012-03-06
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
oursql
Undecided
Unassigned

Bug Description

Hi,

Python: 2.7
MySQL client: 5.1.41-3ub
oursql: 0.9.3

I had posted a question about the same problem last summer:

https://answers.launchpad.net/oursql/+question/166877

I updated to the latest version of oursql but it seems that the bug is still there.

In a nutshell, Cursor.executemany doesn't work--or maybe I don't know how to make it work, in which case I would appreciate a better explanation in the documentation.

Traceback (most recent call last):
  File "execmany.py", line 9, in <module>
    cu.executemany(query, params)
  File "cursor.pyx", line 138, in oursql.Cursor.executemany (oursqlx/oursql.c:16
097)
  File "statement.pyx", line 278, in oursql._Statement.execute (oursqlx/oursql.c:8906)
oursql.ProgrammingError: (None, 'executing this query would cause rows to become unfetchable', None)

There seem to be a problem with setting the data_waiting attribute in statement.pyx:_Statement but I cannot tell how to fix it. The way I call executemany is the following:

query = 'select user_id, user_registration from user where user_id = ?'
params = zip([1,2,3,4,5,123,312,35142,4354252,534124])
cu = c.cursor()
cu.executemany(query, params)

Any help would be really appreciated!

Stephen Thorne (jerub) wrote :

Hi, I just had a look at this problem.

What are you expecting here? If you call executemany() with a select query, you're selecting data and throwing it away immediately..

This error message is saying you've not looked at your result set before doing another query.

Hi Stephen
thanks for the clarification. I thought you could have used executemany() for a SELECT in conjunction with nextset(), but I see that that method is used together with callproc().

Cheers,

Jeff Y. (jeff-w) wrote :

I also expected executemany() to work with SELECT statements.

Could we please add this info to the documentation?

Thanks!

Jeff Y. (jeff-w) wrote :

Although, re-using prepared statements is a use case for executemany() with SELECTs.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers