[DB-SIG] Again a question concering the API from a newbie
Anthony Baxter <firstname.lastname@example.org>
Sat, 20 Sep 1997 17:31:52 +1000
>>> Oliver Andrich wrote
> can anybody give me an example for execute(operation, params)? I mean
> something where I can learn from what this thing with the params means and if
> this is the case with my mySQL interface or not.
an example of this would be something like
curs.execute("""INSERT INTO test_table
VALUES ( :1, :2, '20-NOV-96' )""", (3,"hello"))
the :1 :2 &c are placeholders in the SQL - the parameters are substituted
in. You can also pass a list of tuples and have it substitute each tuple
Why would you do this? It's somewhat neater than string interpolation,
and it saves having to reparse the SQL each time.
I don't have my Oracle docs here, so I can't tell you the fancy term they
use for this - input binding, I think...
DB-SIG - SIG on Tabular Databases in Python
send messages to: email@example.com
administrivia to: firstname.lastname@example.org