[DB-SIG] Preparing statement API
Eric Brunson
brunson@Level3.net
Wed, 26 Jan 2000 10:22:49 -0700
--ZfOjI3PrQbgiZnxM
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
* M.-A. Lemburg (mal@lemburg.com) [000126 10:06]:
> Hrvoje Niksic wrote:
> >=20
> > "M.-A. Lemburg" <mal@lemburg.com> writes:
> >=20
> > > > statement =3D cur.prepare("INSERT INTO foo (user, name) VALUES =
(?, ?)")
> > [...]
> > > The problem with this approach is that you'd have to store the
> > > perpared information somewhere. This is usually done by the cursor
> > > which is not under Python's control.
> >=20
> > You'd store it (or a pointer to it) in the statement object, returned
> > by cursor.prepare(). Given that prepare() is a cursor method, the
> > cursor can be made aware of each such object.
> >=20
> > > cursor.prepare(operation)
> > > Prepare a database operation (query or command) statement for
> > > later execution and set cursor.command. To execute a prepared
> > > statement, pass cursor.statement to one of the .executeXXX()
> > > methods.
> > >
> > > cursor.command
> > > Provides access to the current prepared SQL command available
> > > through the cursor. This is set by .prepare(), all catalog
> > > methods, .execute() and .executemany().
> >=20
> > This is very close to what I proposed, except that my cursor.prepare()
> > returns the statement (which you provide through cursor.command).
> > This allows one to prepare more than one statement using one cursor.
>=20
> Maybe this is just an ODBC thing, but you cannot prepare more
> than one statement on a cursor (in ODBC the notion of cursors
> is captured by the HSTMT or statement handle). For ODBC, your
> .prepare() function would have to return a new cursor.
>=20
That seems to be true of the DCOracle implementation, also. Yesterday
I tried to reuse a cursor object and it failed, I had to declare a new
one. This may be why they put the prepare() method in the connection
object.
--=20
Eric Brunson * _ o * Faster and faster, =
=20
brunson@brunson.com * / //\ until the thrill of speed =
=20
brunson@level3.net \>>| * overcomes the fear of death
page-eric@level3.net \\, =20
--ZfOjI3PrQbgiZnxM
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.0 (SunOS)
Comment: For info see http://www.gnupg.org
iD8DBQE4jy1nQDyMrcmL1RcRAU7RAJ4pb4d2zwXVDB8AhJnyk5FGGtR1mQCfQAMt
4QkbTDgy5sm561KBdIb48w0=
=PqLB
-----END PGP SIGNATURE-----
--ZfOjI3PrQbgiZnxM--