[DB-SIG] Towards a single parameter style

Federico Di Gregorio fog@initd.org
24 Feb 2003 19:40:12 +0100


--=-D5Lg7ugITh1PX7/ItKVb
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

Il lun, 2003-02-24 alle 15:42, Anthony Tuininga ha scritto:
[snip]
> Exposing a prepare method would be convenient only in the sense of
code
> abstraction and code simplicity and such nebulous things. :-)
> Specifically, you can do the following (or something similar)
>=20
> def use_cursor(cursor, **parameters):
>     cursor.execute(None, parameters)
>     # some drivers use cursor.execute(cursor.statement, parameters)
>     for row in cursor.fetchall():
>         do_stuff()
>=20
> cursor =3D connection.cursor()
> cursor.prepare(sql_1)
> use_cursor(cursor)
> cursor.prepare(sql_2)
> use_cursor(cursor)

let me say i would never write code like that. i am not saying it is
particulary bad or good. simply it doesnot suit my programming habits.=20

now, adding complexity to an API to follow someone's programming habits
is bad, imho. especially if you can obtain the same effect in a
different, already estabilished way.
=20
> If the cursor cannot be prepared in advance, you must pass the SQL
> through in addition to the cursor. That makes it unclear whether or
not
> the cursor has truly been prepared or not and whether the statement
> being executed is really the one you intend to execute. If that
doesn't
> make sense, ask me a different question. :-)

this is a very good reason to *not* have prepare(). :)

--=20
Federico Di Gregorio
Debian GNU/Linux Developer                                fog@debian.org
INIT.D Developer                                           fog@initd.org
  99.99999999999999999999% still isn't 100% but sometimes suffice. -- Me

--=-D5Lg7ugITh1PX7/ItKVb
Content-Type: application/pgp-signature; name=signature.asc

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

iD8DBQA+WmcMvcCgrgZGjesRAtR6AJ9cravV0IAp8Q5SmrkemQUsClOcewCgqq2P
di8wSgvjBw/oTfoht9hPg60=
=ZgXY
-----END PGP SIGNATURE-----

--=-D5Lg7ugITh1PX7/ItKVb--