[DB-SIG] Mandatory parameters in execute

Andy Dustman adustman@comstar.net
Tue, 16 May 2000 12:23:44 -0400 (EDT)

On Tue, 16 May 2000, Thierry MICHEL wrote:

> hi *,
> 	a imple question: the arguments prameter in the execute()
> function (DBAPI 2.0) is marked as optional. that's right because
> if you do a SELECT you don't need to pass any parameters? but what
> about INSERTs? if the use of `arguments' is mandatory it is really
> easy to control the types of the argument and do some conversions
> (arrays and large objects, for example.) so the question is, if
> the driver sets paramstyle to pyformat the user can build an INSERT
> string outside of execute() and then use it or is he forced to build
> the INSERT string by passing arguments python-style?

I would think that all databases would allow you to build your own literal
query statement that didn't use any parameter substitutions. In fact,
Zope's Database Adapter interface depends upon this. MySQL, of course,
doesn't actually use any parameter substitutions at all; these are
implemented in the Python portion of MySQLdb. So, yes, the user ought to
be able to build the INSERT query outside of execute() in all cases. 

andy dustman       |     programmer/analyst     |      comstar.net, inc.
telephone: 770.485.6025 / 706.549.7689 | icq: 32922760 | pgp: 0xc72f3f1d
"Therefore, sweet knights, if you may doubt your strength or courage, 
come no further, for death awaits you all, with nasty, big, pointy teeth!"