[DB-SIG] Is there a better way of doing this?

Federico Di Gregorio fog@initd.org
06 Jun 2002 16:36:02 +0200


--=-2o7ijsTeoOHY6nXnffMw
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

Il gio, 2002-06-06 alle 16:26, Matthew T. Kromer ha scritto:
[super snip]
> It seems to me fetch should actually return an empty set when it cannot=20
> fetch more records, and the application should check for a zero-length=20
> return set.   Arguably, I violate the DB 2.0 API spec by doing this in=20
> DCOracle2.

he's trying to write a generalized function that can be used to execute
queries and return results if present. i think the dbapi specifies that
after a SELECT an empty set can be returned by the fetchXXX functions
but an exception is raised if the query was not a SELECT. you can trust
rowcount because it can be >0 after any query (not only SELECT).

a solution that can be used on psycopg is to test the .description
attribute; it is a tuple after a SELECT and None in any other case, but
I don't know if that is portable.

--=20
Federico Di Gregorio
Debian GNU/Linux Developer & Italian Press Contact        fog@debian.org
INIT.D Developer                                           fog@initd.org
  The devil speaks truth much oftener than he's deemed.
      He has an ignorant audience. -- Byron (suggested by Alice Fontana)

--=-2o7ijsTeoOHY6nXnffMw
Content-Type: application/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQA8/3NSvcCgrgZGjesRAo5kAKCC2U5Qw0Mj//VgwmZTzQZeqRj4nwCfeyuu
buhNjKERwuSve5VWoB3g3oQ=
=YAU+
-----END PGP SIGNATURE-----

--=-2o7ijsTeoOHY6nXnffMw--