On 2007-05-23 13:37, Carsten Haese wrote:
> On Wed, 2007-05-23 at 12:36 +0200, M.-A. Lemburg wrote:
>> Just an aside:
>>
>> Note that the named style allows binding the same parameter
>> more than once.
> 
> Ditto for numeric style.
> 
>> This poses a few problems for interfaces which
>> rely on the database telling the interface how to best bind
>> a parameter, since it may well be that case that a parameter
>> needs to be bound as e.g. integer in one place (e.g. as index)
>> and float in another (e.g. if used in a formula).
>>
>> For numbers, it's fairly obvious what to do (create multiple
>> bindings for the object), but it's not for objects that don't
>> easily allow retrieving the same value twice, such as
>> iterators or files.
>>
>> I don't know how interfaces that do support named style deal
>> with this problem.
> 
> InformixDB supports binding by name, and in the real world this is not a
> problem at all. The parameter values must be supplied in a mapping, and
> the input binding loop simply calls __getitem__ on that mapping,
> possibly requesting the same key twice. If the same key is requested
> twice, you'd have to work hard to make that *not* return the same object
> twice. You'd have to pass in a dictionary-like object whose __getitem__
> method has deliberate side-effects, and if you do that, you deserve to
> be punished.

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.

Regards,
-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, May 23 2007)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
_______________________________________________
DB-SIG maillist  -  DB-SIG@python.org
http://mail.python.org/mailman/listinfo/db-sig

Reply via email to