[DB-SIG] paramstyles, again

Carsten Haese carsten at uniqsys.com
Wed May 23 14:32:41 CEST 2007


On Wed, 2007-05-23 at 13:52 +0200, M.-A. Lemburg wrote:
> That's not what I was asking. The problem (or maybe it's a non-issue
> in the real word) is: what happens at binding time to the data
> fetched from the object you bind to a command parameter, e.g.
> say the interface supports reading data from a file (instead of
> just using a string):
> 
> file = open('my.dat', 'rb')
> cursor.execute('insert into mytable values (:data, :data)',
>                {'data': file})
> 
> In theory, the interface would have to read and buffer
> the data from the file in order to be able to provide
> two bindings to the database.

I see. That would require a database interface that implicitly reads the
file's contents when that file is bound as an input parameter. I don't
know of any interfaces that do that, and I would find that behavior
rather surprising. Remember, explicit is better than implicit. If I
wanted the file to be read, I'd read it explicitly.

The only way that I see for how the file contents could be read
implicitly upon input binding would be if some kind of inputmap were
involved, possibly of the kind I proposed before this thread was
hijacked. The problem could then be avoided by memoizing the result of
the adapter call, either in the adapter function itself or within the
DB-API layer.

Best regards,

-- 
Carsten Haese
http://informixdb.sourceforge.net




More information about the DB-SIG mailing list