[DB-SIG] cx_Oracle - passing unnecessary bind variables
Bob Gailer
bgailer at alum.rpi.edu
Thu Nov 20 20:42:53 EST 2003
At 02:01 PM 11/20/2003, Paul Moore wrote:
>I'm trying to write a function, using cx_Oracle, which allows the user
>to specify a SQL statement, to be executed with some bind variables
>out of a common set.
>
>Example:
>
> class Collector:
> def __init__(self, cn, **kws):
> self.vars = kws
> def execute(sql):
> c = cn.cursor()
> c.execute(sql, self.vars)
> c.close()
>
>This is a simplified example, but the basic usage is something like
>this:
>
> cn = cx_Oracle.connect(...)
> coll = Collector(cn, a=12, b=24, c=11, d=13)
> coll.execute("insert into t1 (a,b) values(:a, :b)")
> coll.execute("insert into t2 (a,c,d) values(:a, :c, :d)")
Here's what I do:
cn.execute("INSERT INTO table1 (col1, col2) VALUES(:id, :key)", id =
1, key = 2)
Bob Gailer
bgailer at alum.rpi.edu
303 442 2625
-------------- next part --------------
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.538 / Virus Database: 333 - Release Date: 11/10/2003
More information about the DB-SIG
mailing list