[DB-SIG] Preparing statement API
Wed, 26 Jan 2000 10:22:49 -0700
Content-Type: text/plain; charset=us-ascii
* M.-A. Lemburg (firstname.lastname@example.org) [000126 10:06]:
> Hrvoje Niksic wrote:
> > "M.-A. Lemburg" <email@example.com> writes:
> > > > 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.
> > 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.
> > > 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().
> > 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.
> 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.
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
Eric Brunson * _ o * Faster and faster, =
firstname.lastname@example.org * / //\ until the thrill of speed =
email@example.com \>>| * overcomes the fear of death
firstname.lastname@example.org \\, =20
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.0 (SunOS)
Comment: For info see http://www.gnupg.org
-----END PGP SIGNATURE-----