[DB-SIG] pyformat Parameter Style
mal at lemburg.com
Tue May 13 13:08:41 EDT 2003
Marcos Sánchez Provencio wrote:
>>That said, I still think that positional binding is by far
>>the easiest to use and understand way of binding variables.
> I see your point, but if you have to use your parameters several times
> in your sql statement it is a little awkward. For example, an optional
> filter parameter (imagine that with a combination of four or five
> select * from xx
> where (yy=[param] or [param] is null)
> and zz=[param2]
Uhm, why would you want to use "[param] is null" in SQL ? You
can check that in Python.
There are situations where you have to do multiple binding,
but that's not really harmful, e.g.
... where col1 > [param1] and col2 < [param1]
There's no additional overhead introduced by this,
since the two occurences of [param1] both refer to the same
Python object and the DB API modul can reuse the already
converted data a second time.
> I always thought this should be encapsulated in a stored procedure until
> I had to use Oracle. Oracle needs writing more than a dozen lines (not
> the intuitive kind, if I may say) to cram that into a stored proc.
Moreover, it's nowhere near as portable to use stored
Professional Python Software directly from the Source (#1, May 13 2003)
>>> Python/Zope Products & Consulting ... http://www.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
EuroPython 2003, Charleroi, Belgium: 42 days left
More information about the DB-SIG