cursor.fetchall fails
Closed this issue · 9 comments
cursor.fetchall fails if the result is larger than the cursor.arraysize. The code throws an exception while I expect all result rows.
I cannot replicate your issue, this works fine:
from pymonetdb import Connection
con = Connection(**settings)
cur = con.cursor()
cur.arraysize = 5
cur.execute('select * from tables, tables')
result = cur.fetchall()
Please supply python version, pymonetdb version, exception, and code example.
Traceback (most recent call last):
File "x.py", line 12, in <module>
print cursor.fetchone();
File "/usr/lib/python2.7/site-packages/pymonetdb/sql/cursors.py", line 446, in fetchone
self.nextset()
File "/usr/lib/python2.7/site-packages/pymonetdb/sql/cursors.py", line 536, in nextset
end = min(self.rowcoTraceback (most recent call last):
File "x.py", line 12, in <module>
print cursor.fetchone();
File "/usr/lib/python2.7/site-packages/pymonetdb/sql/cursors.py", line 446, in fetchone
self.nextset()
File "/usr/lib/python2.7/site-packages/pymonetdb/sql/cursors.py", line 536, in nextset
end = min(self.rowcount, self.rownumber + self.arraysize)
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'
unt, self.rownumber + self.arraysize)
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'
Python 2.7.14
python-pymonetdb-1.1.0-1.fc26.noarch
cursor = cursors.Cursor(connection)
#cursor.arraysize = 200
res = cursor.execute("SELECT sensor_id, description FROM sensors")
print res
for i in range(0,res):
print cursor.fetchone();
``
(or replace the for loop with a fetchall)
I still can't replicate this problem. What MonetDB version are you using?
MonetDB5-server-11.27.11-20171204.fc26.x86_64
@ankravch what do you mean with incompatible types? Cursor.arraysize
should never be None
. If it is None
then it is manually set to None (which is invalid) or it is a bug, but I don't understand where.
hi @ankravch . Sorry for the delay in replying, I forgot about this issue.
Its true that replysize
is set to None
, but in the same function it is directly set to a valid value:
https://github.com/gijzelaerr/pymonetdb/blob/master/pymonetdb/sql/connections.py#L63
Effectively that means that replysize
is never None
outside that scope. That statement is only there to make the typing checking logic happy.
default is 0 now.