[DB-SIG] There is a better way

Richard Taylor r.taylor@eris.qinetiq.com
Wed, 12 Jun 2002 10:03:41 +0100


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wednesday 12 June 2002 9:29 am, M.-A. Lemburg wrote:
> Richard Taylor wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > On Wednesday 12 June 2002 7:22 am, Stuart Bishop wrote:
> >>On Friday, June 7, 2002, at 08:34 PM, Richard Taylor wrote:
> >>>        if cr.description == None or cr.rowcount == 0 :
> >>>            return []
> >>>
> >>>        try:
> >>>            res = cr.fetchall()
> >>>
> >>>
> >>>I would welcome comments on whether this will work on all DB API
> >>>modules.
> [snip]
> The .rowcount variable must be set to -1 if it is unknown for
> some reason, e.g. if no query has been executed on the cursor
> of the database does not have the information available.
>
> A .rowcount of 0 always indicates that the result set is
> empty. Unfortunately, some database drivers and interfaces
> are broken in this respect (including some ODBC drivers
> out there), so applications should be aware of this.

So that means that the original code should work if the driver is not broken?

i.e.

 if cr.description == None or cr.rowcount == 0 :
       return []

Richard


- -- 
QinetiQ                                  
B105 Woodward Building
St. Andrews Road
Malvern
Worcs WR14 3PS

The Information contained in this E-Mail and any subsequent correspondence
 is private and is intended solely for the intended recipient(s).
 For those other than the recipient any disclosure, copying, distribution, 
or any action taken or omitted to be taken in reliance on such information is
 prohibited and may be unlawful.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9Bw5t7Z7YaKfan9kRAlL/AJkBtTdm/o76sEuwJNZTHKqdn0gmzACffDQx
C3BXbmeKaKIPJjonI80+C5s=
=XGzq
-----END PGP SIGNATURE-----