[PYTHON DB-SIG] RE: Looking for examples of oracledb usage
Harold Poskanzer
hmp@infoseek.com
Mon, 21 Apr 1997 15:26:14 -0700
Would you believe I was wondering what the oracledbmodule bind variable syntax
was the night before I got this email?
I have one question, though: I assume I can do :0 through :9 easily, but how
do I do more than 10 bind variables?
-H
=====================================================================
Harold Poskanzer Software Engineer
Infoseek Corporation hmp@infoseek.com
2620 Augustine Dr #250 Phone: 408/567-2741
Santa Clara, CA 95054 http://www.infoseek.com/
---------------------------------------------------------------------
Proof of Intelligent Life on the Net
> The :N syntax uses database facilities for "binding" the parameter
> values to the SQL statement, while the form you mention is simply
> altering the SQL statement that gets sent to the database. There are
> several benefits to using parameter binding:
>
> 1) you don't need to worry about escaping string values
> 2) certain types of values *can't* be specified in the SQL
> statement (typically, LONG/BLOB/IMAGE.. whatever you want to call it)
> 3) you can actually achieve higher efficiencies using parameter
> binding. The standard sequence of operations with a database is: parse
> the statement, bind parameters, execute the statement, fetch the
> results. With parameter binding, you can fill in values to the bound
> memory and re-execute the statement (skipping the parse/bind steps). By
> altering the SQL string, you have to go through all the steps again. The
> parse step is surprisingly expensive!
>
> You will see the use of "?" in some database interfaces rather than the
> :N syntax (which comes from Oracle, actually). The :N variety was chosen
> because binding positionally is quite handy in a variety of contexts.
>
> I hope that clears things up!
>
> -g
>
> -----Original Message-----
> From: Daniel Larsson
> [SMTP:Daniel.Larsson@vasteras.mail.telia.com]
> Sent: Thursday, April 17, 1997 1:17 PM
> To: python-list@cwi.nl
> Subject: Re: Looking for examples of oracledb usage
>
>
> Anthony Baxter wrote in article
> <199704150430.OAA01115@jambu.off.connect.co
> m.au>...
> >
> >something like
> >
> >curs.execute("select * from db where blah = :1 and foo =
> :2",(123,456))
> >
> >works for me.
>
> In general, how does this differ from using the standard string
> formatting,
> e.g.
>
> curs.execute("select * from db where blah = %d and foo = %d" %
> (123, 456))
>
> (I assume these examples are equivalent, but I'm asking for the
> general
> case)
>
> >>>> Roy Smith wrote
> >> I'm looking for example of python code that uses the oracledb
> module.
> >> I've got simple stuff working, but havn't yet figured out how
> to do
> >> variable binding in an execute call. The documentation says,
> "Variables
> >> are specified in a database-specific notation that is based
> on the
> index
> >> in the parameter tuple (position-based rather than
> name-based)", but
> I'm
> >> not quite sure what all that means.
> >
>
>
> _______________
> DB-SIG - SIG on Tabular Databases in Python
>
> send messages to: db-sig@python.org
> administrivia to: db-sig-request@python.org
> _______________
--
_______________
DB-SIG - SIG on Tabular Databases in Python
send messages to: db-sig@python.org
administrivia to: db-sig-request@python.org
_______________