[DB-SIG] Clarification of cursor.arraysize

M.-A. Lemburg mal at egenix.com
Tue Dec 19 01:01:35 CET 2006


On 2006-12-18 22:56, Art Protin wrote:
> Dear folks,
>     I find yet again that I am confused by what I read in pep-0249.  
> This time it is the last line describing the attribute of cursor objects 
> named .arraysize (I quote here both paragraphs):
> 
>     This read/write attribute specifies the number of rows to
>     fetch at a time with fetchmany().  It defaults to 1 meaning
>     to fetch a single row at a time.
> 
>     Implementations must observe this value with respect to
>     the fetchmany() method, but are free to interact with the
>     database a single row at a time.  It may also be used in
>     the implementation of executemany().
> 
> I fail to grasp how .arraysize could have any bearing on .executemany() 
> or for that matter any operation other than fetchmany().  Thus I find I 
> must request aid in understanding what the intent is here - HELP,  please.

It's actually very simple: .arraysize specifies the default for
the parameter to .fetchmany().

>       While I am bothering you good people with my silly questions, I 
> might just as well tack on another:  if one invokes .executemany with a 
> seq_of_parameters that is empty (like
> 
> a_cursor.executemany(SQL, [])
> 
> ) shouldn't the interface module execute the query zero times, ie, not 
> execute the query at all?

The SQL command could be a command that doesn't have any parameters.
In such a case, the above would be the same as .execute(SQL).

I agree that this is a somewhat constructed case, but it can
occur in situations where you write generic code for e.g.
database abstraction layers.

> I think that is what I am going to do but I would like to hear your 
> comments either way.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Dec 19 2006)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::


More information about the DB-SIG mailing list